Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu root remains displayed when action from sub-menu is selected #312

Open
andrewdavidmackenzie opened this issue Dec 6, 2024 · 17 comments

Comments

@andrewdavidmackenzie
Copy link
Contributor

I have a menu bar, with a number of menu roots on it ("hardware:...." in the image below)

One (the mentioned "hardware:..." menu) has sub menus (one for each device discovered, such as "Fake RPi (...)")

That sub-menu has menu items that are actions on the device (such as "Connect to Device" and "Display Device details..." shown in the image below).

image

When I select the menu item (e.g. "Connect to Device" in the image), the sub-sub-menu closes, the sub-menu closes but the root menu remains displayed, obscuring part of the UI that is changing due to the action (the mouse pointer is no longer over any part of the menu that remains displayed).

image

Is this the intended behaviour?
Is there a way I can get the menu to close when an action is selected?

@genusistimelord
Copy link
Collaborator

hmm no that is not intended behavior they should all be closing.

@Ultraxime
Copy link
Contributor

Hi
Can you give a minimalist example of the bug ?

@andrewdavidmackenzie
Copy link
Contributor Author

I'd have to create an app that has only that....

@genusistimelord
Copy link
Collaborator

basically we would like you to try and recreate it in the most minimal possible way So we can find the issues causing it. This also ensures the issue is only the menu widget and does not have to do with some other control etc etc..

@andrewdavidmackenzie
Copy link
Contributor Author

I was taking a look at the menu example. I see none of the "leaf nodes" do any action that closes any of the menus.
Changing that would (IMHO) make sense for the demo and maybe reproduce the issue?

I'll try to do that in my fork.

@andrewdavidmackenzie
Copy link
Contributor Author

I wonder if it is related to our use of a "fake" Message in menu clicks, such as this:

    Item::with_menu(
        button(text(model))
            .on_press(Message::MenuBarButtonClicked) // Needed for highlighting
            .style(move |_theme, status| {
                if status == Hovered {
                    MENU_BAR_BUTTON_HOVER_STYLE
                } else {
                    MENU_BAR_BUTTON_STYLE
                }
            }),
        Menu::new(menu_items).width(215.0).offset(10.0),
    )

Without it, we cannot get menus to highlight on hover (items do, but not the root or sub-menus that have items).

I notice example menus do, so not sure why we can't get that to work?
I tried uncommenting those lines again, and the highlighting on menu hover stops.

@genusistimelord
Copy link
Collaborator

hmm does the menu close fine without that? if so it could be the button is returning an event saying it was processed and the menu is then not processing much else.

@andrewdavidmackenzie
Copy link
Contributor Author

andrewdavidmackenzie commented Dec 12, 2024 via email

@andrewdavidmackenzie
Copy link
Contributor Author

Removing those on_press() call - No Change

@andrewdavidmackenzie
Copy link
Contributor Author

When the action is performed (after on_select) - the menu contents update (that was causing a panic which we fixed in a prior PR), not sure if that is relevant for the fact it doesn't close. Maybe the logic for closing is skipped due to the "fix" in the PR that fixed the panic?

@genusistimelord
Copy link
Collaborator

could very well be the issue. Can you see about making a minimal Example with the issue so we can rule out anything else?

@Ultraxime
Copy link
Contributor

How do you catch your "fake" message ?
If you do it in an event method or something like that, did you propagate to the shell the invalidation of the widget or layout ?

@andrewdavidmackenzie
Copy link
Contributor Author

in update() of the app, with an empty entry:

https://github.com/andrewdavidmackenzie/pigg/blob/master/src/piggui.rs#L293

@Ultraxime
Copy link
Contributor

So it's a real event you just do nothing.

I now that for what you are doing instead of using a button, I used a badge and I don't get you issue.

But even with the button it shouldn't be an issue, I'll look into it. But it would be awesome if you could do a minimal example of the bug.

@andrewdavidmackenzie
Copy link
Contributor Author

andrewdavidmackenzie commented Dec 13, 2024 via email

@genusistimelord
Copy link
Collaborator

any updates on getting the minimal example?

@andrewdavidmackenzie
Copy link
Contributor Author

andrewdavidmackenzie commented Dec 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants