I want to prevent the SubMenu
from opening and closing its child menu items when you click on it. Is there a way to do this without setting it to disabled
? (Which affects how the button looks) I essentially want the SubMenu to look the same, without toggling functionality of its children.
I want to prevent the SubMenu
from opening and closing its child menu items when you click on it. Is there a way to do this without setting it to disabled
? (Which affects how the button looks) I essentially want the SubMenu to look the same, without toggling functionality of its children.
-
Do you mean you want to keep a
SubMenu
open all the time? – Dennis Vash Commented Aug 5, 2019 at 14:08
1 Answer
Reset to default 7To achieve the desired behavior, you need to use bination of openKeys
and onOpenChange
properties of Menu
like so:
const OPEN_KEYS = ['sub1'];
export default function App() {
const [openKeys, setOpenKeys] = useState(OPEN_KEYS);
const onOpenChange = openKeys => setOpenKeys([...OPEN_KEYS, ...openKeys]);
return (
<FlexBox>
<Menu
openKeys={openKeys}
onOpenChange={onOpenChange}
>
...
</Menu>
</FlexBox>
);
}
In the above example, OPEN_KEYS
will always stay open and won't affect its Menu.Item
/ Menu.ItemGroup
children.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745063164a4609088.html
评论列表(0条)