Skip to content

Commit

Permalink
remove default auto-close prop from ui.menu (fixes #2894)
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Apr 15, 2024
1 parent dca25d3 commit 2a46e24
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
11 changes: 5 additions & 6 deletions nicegui/elements/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ def __init__(self, *, value: bool = False) -> None:
Creates a menu based on Quasar's `QMenu <https://quasar.dev/vue-components/menu>`_ component.
The menu should be placed inside the element where it should be shown.
Advanced tip:
Use the `auto-close` prop to automatically close the menu on any click event directly without a server round-trip.
:param value: whether the menu is already opened (default: `False`)
"""
super().__init__(tag='q-menu', value=value, on_value_change=None)
self._props['auto-close'] = True

def open(self) -> None:
"""Open the menu."""
Expand Down Expand Up @@ -65,11 +67,8 @@ def __init__(self,
self._props['clickable'] = True

self.menu = self._find_menu()
if self.menu:
if auto_close:
self.on_click(self.menu.close)
else:
self.menu.props(remove='auto-close')
if self.menu and auto_close:
self.on_click(self.menu.close)

def _find_menu(self) -> Optional[Union[Menu, ContextMenu]]:
element: Element = self
Expand Down
10 changes: 10 additions & 0 deletions website/documentation/content/menu_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,14 @@ def main_demo() -> None:
ui.menu_item('Close', menu.close)


@doc.demo('Client-side auto-close', '''
Use the `auto-close` prop to automatically close the menu on any click event directly without a server round-trip.
''')
def auto_close():
with ui.button(icon='menu'):
with ui.menu().props('auto-close'):
toggle = ui.toggle(['fastfood', 'cake', 'icecream'], value='fastfood')
ui.icon('', size='md').bind_name_from(toggle, 'value')


doc.reference(ui.menu)

6 comments on commit 2a46e24

@lelit
Copy link

@lelit lelit commented on 2a46e24 Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick, the 1.4.22 tag does not include a corresponding version bump in pyproject.toml

@falkoschindler
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lelit This should be done automatically by the build process.

@lelit
Copy link

@lelit lelit commented on 2a46e24 Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! Just to understand: does that mean that the tag will be rewritten by the process?

@lelit
Copy link

@lelit lelit commented on 2a46e24 Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is: if I fetch the tag's tar.gz from github and build a local wheel, I'd expect obtaining a wheel with a version matching the tag name, but that's currently not the case, right?

@falkoschindler
Copy link
Contributor Author

@falkoschindler falkoschindler commented on 2a46e24 Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the PyPI and Docker release 0e53ffe has been automatically created by the GitHub build action.
The whole process takes a few minutes, which is why you still got the old tag name. But now the main branch should be up to date.

@lelit
Copy link

@lelit lelit commented on 2a46e24 Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for the explanation (and work 😉 !)

Please sign in to comment.