Close submenu when clicked on submenu item? #826
Replies: 3 comments 1 reply
-
It turns out javascript DOM manipulation do the trick. <ul class="menu menu-horizontal p-0">
<li tabindex="0">
<a onmouseover="document.getElementById('aa').style.display = 'block'">
...
</a>
<ul id="aa" class="p-2 bg-base-300 right-0">
<li><a href="#" onclick="document.getElementById('aa').style.display = 'none'">Submenu 1</a></li>
<li><a href="#">Submenu 2</a></li>
</ul>
</li>
</ul> However I wonder if there is an tailwind/daisyUI native way to handle this? |
Beta Was this translation helpful? Give feedback.
-
import React, { useState } from 'react'; const { SubMenu } = Menu; const MyMenu = () => { const onOpenChange = (keys) => { const handleClick = () => { return ( <Menu.Item key="SubMenu1" onClick={handleClick}>Submenu 1</Menu.Item> <Menu.Item key="SubMenu2" onClick={handleClick}>Submenu 2</Menu.Item> ); }; export default MyMenu; ===================== |
Beta Was this translation helpful? Give feedback.
-
Hi Guys,
Is there a way to close submenu when clicked on submenu item?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions