Better menu #4150
ed2050
started this conversation in
Show and tell
Better menu
#4150
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
After discussion #4108 I made a better menu to replace
ui.menu
. Very easy, less than hour to make.Advantages
Why is it better?
ui.menu
/ui.menu_item
distinctionsui.menu
fails on hover-open and hover-close with nested submenus (see Open menu on hover? #4108)Qmenu
deletes menu items entirely from DOM when menu closes, adds them back (recreates?) when menu opened. If you rely on DOM nodes being present, don't useui.menu
.Some of these things you can do with
ui.menu
but it's a pain (such as adding and dynamically updating open/close arrows on menus). Other things aren't possible unless you really dig into custom js and change Quasar behavior.Code
New menu is very simple, built with
ui.expansion
. Just one short function to build the menu:Now just a bit of css to pretty it up:
And voila. So easy a caveman could do it!
Other improvements
Of course more could be done. Supporting arbitrary elements as menu items, alternative layouts like horizontal menus, etc. Quite easy to customize for your own project. You could even turn it into a custom nicegui component for general-purpose use.
Hope others find this interesting.
Beta Was this translation helpful? Give feedback.
All reactions