Skip to content
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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

onehanddev
Copy link
Contributor

Improve Menu Navigation and Fix Highlighting Issue

  • Fixed bug where parent expandable menu item is getting highlighted along with the its sub menu with keyboard navigation.
  • Improved navigation by resetting parent menu's highlight state when entering a submenu.

Fixes #1197

…s, allowing for dynamic updates to the active (highlighted) item index. This fixes not updating hover out behaviour of navigation for keyboard events.
Copy link

netlify bot commented Jan 8, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 6281f1b
🔍 Latest deploy log https://app.netlify.com/sites/base-ui/deploys/6785f71a9d0ef80008287d50
😎 Deploy Preview https://deploy-preview-1310--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mui-bot
Copy link

mui-bot commented Jan 8, 2025

Netlify deploy preview

https://deploy-preview-1310--base-ui.netlify.app/

Generated by 🚫 dangerJS against 03c6581

@onehanddev
Copy link
Contributor Author

@atomiks Please disregard the older PR and review this one instead.

Copy link
Contributor

@atomiks atomiks left a 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

@zannager zannager added the component: menu This is the name of the generic UI component, not the React module! label Jan 10, 2025
@onehanddev
Copy link
Contributor Author

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');
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atomiks Done 👍

@atomiks
Copy link
Contributor

atomiks commented Jan 16, 2025

It looks like setting the active index to null has a problem with tabbing. When opening the submenu, tabbing backwards should tab to the submenu trigger first, and then the root trigger. Tabbing forward from the root trigger should focus the submenu trigger and then the last known highlighted item in the submenu popup. (This is what happens currently)

But this no longer happens since tabindex=0 is removed with this change when setting the activeIndex to null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: menu This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Menu] Submenu triggers retain data-highlighted when focus has moved to submenu popup using keyboard
4 participants