-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
bug: Dropdown does not close in an intuitive way #3382
Comments
Thank you @mkmoisen
for reporting issues. It helps daisyUI a lot 💚
|
Using Using CSS focus, the behavior of clicking the button again to close the dropdown is fixed in daisyUI 5 (beta) About the expectation of dropdown being closed with choosing an item:
Let me know if you have a question. |
Hi @saadeghi what you say makes sense, it is ambiguous as to what should happen when an item is clicked. I do think it would be a good idea for DaisyUi's documentation to include javascript examples. For example here: https://daisyui.com/components/dropdown/#dropdown-menu-using-details-tag Right now it shows three example tabs: preview, html, JSX. Perhaps it could have some extra tabs for how to implement the various behaviors in javascript, react, svelte. Today you have to google "daisyui dropdown how to close". As an aside, how stable do you think DaisyUI 5 is? If we don't mind minor breaking of backwards compatibility do you think we can give it a shot? |
Agreed. I will add more details to docs.
Release notes are here: https://v5.daisyui.com/docs/v5-beta/ Let me know if you have a question. |
What version of daisyUI are you using?
https://play.tailwindcss.com/wWndQ9FxeZ
Which browsers are you seeing the problem on?
Chrome, Firefox
Reproduction URL
https://play.tailwindcss.com/wWndQ9FxeZ
Describe your issue
The DaisyUI dropdown method does not close in an intuitive way.
I suggest at the minimum there should be a react or svelte example on how to get it working with javascript in the documentation.
However I do wonder if making this close in an intuitive way by default would be a better fix.
The intuitive closing behavior is that the dropdown will close:
Perhaps the first two could happen automatically in the DaisyUI component while the third item would require some custom JS.
Method 1:
It does however close when you click the "open or close" button.
Fixing this with javascript is relatively easy. Here it is in Svelte:
Method 2:
However it does close when you click outside.
Method 2 is harder to fix with javascript.
You need a handleClick and invoke a blur():
In addition you still need a handleOutsideClick function to set
open = false
when the user clicks outside.The text was updated successfully, but these errors were encountered: