thedodd / ybc

A Yew component library based on the Bulma CSS framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Close navbar-dropdown on item click

Follpvosten opened this issue · comments

I'm writing a simple app using ybc and yew-router, triggering routing by using href on navbar items.
Some of these are in a navbar-dropdown, and I've noticed that the dropdown only closes when you click on the overlay, but not when you click on an item in the dropdown; this doesn't really work for my usecase, where the dropdown is used like a menu to navigate the page as described above.
I think this could be fixed by (maybe optionally) internally handling the onclick event on the dropdown itself, which should catch any clicks on its children if they're not getting cancelled (so this approach would still allow overriding this behavior for specific items in any case).
Would you be interested in a PR implementing a feature like that? And if so, should it be an option or the default case? And if it should be optional, what should I call the property on NavbarDropdown?

Hey there @Follpvosten! That sounds pretty reasonable. You could also just use the hover functionality on the dropdown. As soon as the user is no longer hovering, then the dropdown will be removed.

Otherwise, the closest functionality that we currently have like that is the Modal and related components. You might find some inspiration there. Keep me posted!