Skip to content

fix(menu): prevent scroll when navigating with arrow keys #19392

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

Merged

Conversation

heloiselui
Copy link
Contributor

@heloiselui heloiselui commented May 15, 2025

Closes #19389

While working on the new Combo Button component for web-components #19218, @thyhmdo was reviewing the PR and noticed there was an unexpected scroll when navigating menu items using the up/down arrow keys. I investigated and found that the same behavior also occurs in the Menu Button.

Changelog

New

  • Prevented unexpected scroll behavior when using ArrowUp or ArrowDown keys to navigate menu items by adding e.preventDefault() in the keyboard handler.

Testing / Reviewing

  1. Go to Web Component Deploy Preview > Menu Button > Experimental Auto Align
  2. Open the menu and use the up/down arrow keys to navigate through menu items
  3. Expected: No scroll jump should occur during navigation

PR Checklist

As the author of this PR, before marking ready for review, confirm you:

  • Reviewed every line of the diff
  • [N/A] Updated documentation and storybook examples
  • [N/A] Wrote passing tests that cover this change
  • Addressed any impact on accessibility (a11y)
  • Tested for cross-browser consistency
  • Validated that this code is ready for review and status checks should pass

Copy link

netlify bot commented May 15, 2025

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit 7e01136
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-web-components/deploys/6825d3a4a2d2060008ad1bc1
😎 Deploy Preview https://deploy-preview-19392--v11-carbon-web-components.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 project configuration.

Copy link

netlify bot commented May 15, 2025

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit 7e01136
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-react/deploys/6825d3a485e4230007e89b7e
😎 Deploy Preview https://deploy-preview-19392--v11-carbon-react.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 project configuration.

Copy link

codecov bot commented May 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.85%. Comparing base (9e05e6f) to head (7e01136).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #19392   +/-   ##
=======================================
  Coverage   84.85%   84.85%           
=======================================
  Files         371      371           
  Lines       14412    14412           
  Branches     4750     4694   -56     
=======================================
  Hits        12229    12229           
- Misses       2036     2037    +1     
+ Partials      147      146    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@ariellalgilmore ariellalgilmore left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@2nikhiltom 2nikhiltom left a comment

Choose a reason for hiding this comment

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

LGTM, the ci checks needs some eyes

@riddhybansal riddhybansal added this pull request to the merge queue May 16, 2025
Merged via the queue into carbon-design-system:main with commit bdc774e May 16, 2025
53 of 58 checks passed
@heloiselui heloiselui deleted the 19389-fix-scroll-behavior branch June 5, 2025 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Unexpected scroll behavior on keyboard navigation in ComboButton and MenuButton
4 participants