-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(16992): Prevent Page Scroll During Keyboard Navigation in MenuButton and ComboButton options #16998
fix(16992): Prevent Page Scroll During Keyboard Navigation in MenuButton and ComboButton options #16998
Conversation
✅ Deploy Preview for v11-carbon-react ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for carbon-elements ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Worked for both ComboButton and MenuButton
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.
Nice fix! I tested by adding a div adjacent to the button with width: 150vh
to trigger a vertical scroll. Keyboard nav works great with no impact on page scroll. 🚀
b4a89ef
…ton and ComboButton options (carbon-design-system#16998) * fix(15337): fix release names in update automation * fix(15337): fix release names in update automation * fix(16992): prevent page scroll keyboard navigation
…ton and ComboButton options (carbon-design-system#16998) * fix(15337): fix release names in update automation * fix(15337): fix release names in update automation * fix(16992): prevent page scroll keyboard navigation
…ton and ComboButton options (carbon-design-system#16998) * fix(15337): fix release names in update automation * fix(15337): fix release names in update automation * fix(16992): prevent page scroll keyboard navigation
…ton and ComboButton options (carbon-design-system#16998) * fix(15337): fix release names in update automation * fix(15337): fix release names in update automation * fix(16992): prevent page scroll keyboard navigation
…ton and ComboButton options (carbon-design-system#16998) * fix(15337): fix release names in update automation * fix(15337): fix release names in update automation * fix(16992): prevent page scroll keyboard navigation
…ton and ComboButton options (carbon-design-system#16998) * fix(15337): fix release names in update automation * fix(15337): fix release names in update automation * fix(16992): prevent page scroll keyboard navigation
Closes #16992
My Initial assumption was that this issue might be related to Floating UI, which we use for positioning. However, after extensive debugging, discovered that the root cause was actually within the Menu component's keyboard navigation logic.
The scrolling issue occurred because the default browser behavior for arrow keys (scrolling the page) was not being prevented when navigating menu items. This led to both the menu focus changing and the page scrolling simultaneously.
e.preventDefault()
allows to control the focus movement through menu items without triggering unwanted page scrolling.Changelog
New
e?.preventDefault()
is added to prevent scroll behaviorChanged
Updated focusItem function in Menu
Testing / Reviewing
Go to deploy preview
Open MenuButton and ComboButton components
Expand the menu and use the arrow keys to navigate through the items. verify no scrolls happen unexpectedly
Verify existing functionality of Menu/MenuButton/ComboButton components are intact