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

Remove no-parent-event prop for ui.menu #713

Closed
falkoschindler opened this issue Apr 3, 2023 · 0 comments
Closed

Remove no-parent-event prop for ui.menu #713

falkoschindler opened this issue Apr 3, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@falkoschindler
Copy link
Contributor

Description

Originally we misunderstood the QMenu API and placed the menu element next to its trigger button:

with ui.row():
    with ui.menu() as menu:
        ui.menu_item('One')
        ui.menu_item('Two')
    ui.button('Menu', on_click=menu.open)
    ui.label('Another element')

This works, but opens the menu event when clicking on "Another element" (or any other element in the row). To prevent that, we set the prop "no-parent-event".

But the correct way to use a QMenu is to wrap it with the trigger button:

with ui.row():
    with ui.button('Menu', on_click=lambda: menu.open()):
        with ui.menu() as menu:
            ui.menu_item('One')
            ui.menu_item('Two')
    ui.label('Another element')

This makes the "no-parent-event" prop ineffective and it can be removed.
Removing "no-parent-event", i.e. activating the parent event for ui.menu even allows removing the button click handler. A button click will automatically open the menu. In short:

with ui.button('Menu'):
    with ui.menu() as menu:
        ui.menu_item('One')
        ui.menu_item('Two')

I think this is very nice. And it's closer to how Quasar works by default. Therefore we want to remove the "no-parent-event" prop. Since it is a braking change, we schedule it for the 1.3.0 release.

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

No branches or pull requests

1 participant