-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
[Menu] Fixed Menu item not toggling highlighted prop when submenu popup is opened using keyboard #1310
base: master
Are you sure you want to change the base?
[Menu] Fixed Menu item not toggling highlighted prop when submenu popup is opened using keyboard #1310
Conversation
…s, allowing for dynamic updates to the active (highlighted) item index. This fixes not updating hover out behaviour of navigation for keyboard events.
…ergeReactProps to merge externalProps
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Netlify deploy preview |
Signed-off-by: Hakimuddin <[email protected]>
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.
A test would be helpful to prevent future regressions
@atomiks Just did, Please check, Thanks ! |
|
||
submenuItems.forEach((item) => { | ||
if (item === submenuItem1) { | ||
expect(item).to.have.attribute('tabindex', '0'); |
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.
Small nit: data-highlighted
is the attribute used for styling so it'd be better to test that, even if they're functionally the same
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.
@atomiks Done 👍
…://github.com/onehanddev/base-ui into menu/submenu-highlight-keyboard-focus-updated
It looks like setting the active index to But this no longer happens since |
@atomiks That was a good find, I have made the change to update the tabindex while nulling the activeIndex, Please checkout my latest commit, Thanks ! |
setIsSubmenuOpen(true); | ||
} | ||
}; | ||
return mergeReactProps(externalProps, { |
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.
mergeReactProps<'div'>(...)
will be able to type the onKeyDown
event automatically
@@ -32,17 +41,37 @@ export function useMenuSubmenuTrigger( | |||
|
|||
const menuTriggerRef = useForkRef(menuItemRef, setTriggerElement); | |||
|
|||
const direction = useDirection(); | |||
|
|||
const [isSubmenuOpen, setIsSubmenuOpen] = useState(false); |
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.
How does this state get reset back to false
when keepMounted=true
is used?
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.
Ah, at the moment, it seems we need to access the ultimate Menu.root open property or state. Based on this, we can reset the isSubmenuOpen to false. However, this could be challenging given that the menu could be nested any number of times. Do you have any approach or solution in mind for handling this?
Improve Menu Navigation and Fix Highlighting Issue
Fixes #1197