-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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
[base-ui][Menu] Fix navigation of items when 1st item is disabled #39828
Conversation
Netlify deploy previewhttps://deploy-preview-39828--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
@@ -122,9 +122,9 @@ export function useMenu(parameters: UseMenuParameters = {}): UseMenuReturnValue | |||
}, [listboxId, registerPopup]); | |||
|
|||
React.useEffect(() => { | |||
if (open && highlightedValue === subitemKeys[0] && !isInitiallyOpen.current) { | |||
if (open && highlightedValue && !isInitiallyOpen.current) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH i don't have context on why subitemKeys[0]
is explicilty used here. instead of focusing subitemKeys[0]
, focusing highlightedValue
seems to fix the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was suspicious seeing it as well, and noticed the same issue while working on adding support for selectable menu items. The changed logic looks good to me 👍 cc @michaldudak for the final review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to admit I don't remember what was my reasoning here. It may be I was trying some things out and forgot to remove it. Thanks for taking care of it, @sai6855!
closes: #39941
Before sandbox
https://codesandbox.io/s/recursing-meadow-mqdl28?file=/src/Demo.tsx
After sandbox
https://codesandbox.io/s/flamboyant-microservice-htz9v4