saadeghi/daisyui

docs: How to maintain state of collapse and expand submenu?

vishal-ainow opened this issue · 3 comments

On which page do you see this issue?

https://daisyui.com/components/menu/

Describe the issue

How to maintain state of collapse and expand submenu? in documentation its only <details open> tag. I'm using astro + svelte.

Screenshot 2024-11-07 at 2 50 33 AM

What browsers are you seeing the problem on?

All browsers

Thank you @vishal-ainow for reporting issues. It helps daisyUI a lot 💚
I'll be working on issues one by one. I will help with this one as soon as a I find a solution.
In the meantime providing more details and reproduction links would be helpful.

Here's docs for HTML <details> tag:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details

Adding or removing open attribute opens or closes the menu. This happens automatically with click (no JS needed) But you can add/remove the open attribute using JS if you want to.

Also if you don't want to use <details> tag you can use spans and class names to get the same UI:
https://daisyui.com/components/menu/#collapsible-submenu-that-works-with-class-names

Let me know if you have a question.

@saadeghi Is it possible to get click event of <details> tag?