-
Notifications
You must be signed in to change notification settings - Fork 82
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 - Menu with all items disabled does not disappear on clicking away #2924
Comments
I've been looking into this interesting behavior and I think I might have found a potential cause. It seems to be related to PR #2741, where items marked as disabled are implemented using the native HTML disabled attribute, which prevents focus/blur events. This explains why having at least one enabled item allows the expected behavior to work. One potential approach could be to use |
import React, { useState, useRef, useEffect } from 'react'; export default function BasicMenu() { const handleMenuToggle = () => { const handleClickOutside = (event) => { useEffect(() => { return ( <Menu.Trigger> <IconButton variant="secondary" icon={} aria-label="toggle menu" onClick={handleMenuToggle} /> </Menu.Trigger> <Menu.List> <Menu.Item disabled>Create an entry</Menu.Item> <Menu.Item disabled>Remove an entry</Menu.Item> <Menu.Item disabled>Embed existing entry</Menu.Item> </Menu.List> ); } I hope this will work. Happy coding :) |
@ManasiRoy, thanks for your suggestion. Did you accidentally paste the wrong code? It seems like you intended to use the Menu as a controlled component, which is a good workaround but it wouldn't fix the behavior for the uncontrolled component when used with only disabled MenuItems. |
Forma 36 bug report
Summary
When having a menu that contains only disabled items, clicking anywhere on the screen does not close it, like it usually would. Only clicking on the
Menu.Trigger
will close it again.Playground reproduction
Environment
MacOS
Browsers: Latest Chrome and Firefox
Steps to reproduce
Expected results
The menu should close when clicking away. Set one of the items to enabled and you'll see the expected behaviour
Actual results
The menu stays open when clicking away.
The text was updated successfully, but these errors were encountered: