Bug #805
closedWMenu wrong nested path selection
0%
Description
In WMenu
, when I use nested internal paths, the content is not updated correctly.
I use the following items in the menu
menu->addItem("items", new Wt::WText("content items"))->setPathComponent("items");
menu->addItem("item1", new Wt::WText("content item 1"))->setPathComponent("items/item1");
When 'item1' receives the first click, itemSelected()
is emitted twice. First for 'item1' (correct), and then again for 'items'. This has the effect that the content of 'items' is shown. On a second click, itemSelected()
is emitted only once, and the content is updated correctly.
This is similar to #693 but doesn't work for me for this case with the latest git (03019b1).
Attached is a small program that illustrates the problem.
Are nested internal paths something that shouldn't be done, or done differently?
Thanks, Michael
Files
Updated by Koen Deforche over 13 years ago
- Status changed from New to Feedback
- Assignee set to Koen Deforche
Hey Michael,
Indeed nested internal paths weren't foreseen. Currently, the first item that matches the current path is considered to be selected. Selecting an item changes the internal path and that's why in this case you get two selection events.
This could be solved by taking only the "most specific" match. And I can't think of anything totally against this, except that the use case seems to be confusing ?
Regards,
koen
Updated by Michael Egli over 13 years ago
Hi Koen,
My idea was to have bookmarkUrl()
's like the following.
products/
products/prod1/
products/prod2/
This would be closer to traditional html URLs, but I can easily rearrange this. It might not make much sense with a Wt application anyway.
However, what I can see is that the content of the sub-item is displayed only on a second click within an ajax session (current Firefox / Chromium). This, I think, is a bit counter-intuitive.
Thanks, Michael
Updated by Koen Deforche over 13 years ago
Hey,
In this case it sounds like you should "root" your menu at "/products" ?
Koen
Updated by Michael Egli over 13 years ago
Hi Koen,
I'm not sure. The products example was only for illustratation. I have other items in my menu that don't point to products.
Also, the documentation of Wt::WApplication::setInternalPath suggests that I should be able to do what I initially wanted.
Michael
Updated by Koen Deforche over 13 years ago
- Status changed from Feedback to Resolved
Hey Michael,
I've implemented the best matching algorithm now and the test case now behaves as expected.
Regards,
koen
Updated by Koen Deforche over 13 years ago
- Status changed from Resolved to Closed