-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[material][Rating] Fix keyboard navigation behavior in Safari #47461
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: master
Are you sure you want to change the base?
Conversation
Netlify deploy previewhttps://deploy-preview-47461--material-ui.netlify.app/ Bundle size report
|
vmaineng
left a comment
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.
This update creates a predictable keyboard flow. The normalization of Safari’s legacy keys and the single handler guard remove the double-step issue nicely. The roving tabIndex logic is also spot-on and aligns well with WAI-ARIA radio patterns. Great job on this!
| @@ -0,0 +1,422 @@ | |||
| import 'docs/src/modules/components/bootstrap'; | |||
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.
What's this file?
| @@ -0,0 +1 @@ | |||
| {} | |||
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.
?
| await renderFixture('Rating/BasicRating'); | ||
|
|
||
| const activeEl = page.locator(':focus'); | ||
| const checked = () => page.locator('input[name="rating-test"]:checked'); |
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.
Why does this test need to change?
Summary
This PR improves the keyboard accessibility and navigation behavior of the Rating component. It primarily focuses on inconsistent/incorrect behavior in Safari. This is because the Safari browser handles focus, radio navigation, and keyboard events differently from other browsers. As a result, keyboard users experienced (BUG):
This PR makes the Rating component fully keyboard-accessible and consistent across all major browsers.
Fix implemented
This PR introduces several improvements that together standardize keyboard behavior:
Cross-browser key handling
"Left","Right","Up","Down"event keys.nextValueForKeyhelper.Reliable, predictable focus behavior (roving
tabIndex)value == null, the “empty” radio hastabIndex=0.tabIndex=0.tabIndex=-1.Single-step arrow key navigation
event.defaultPreventedinsidehandleKeyDownso that:Consistent behavior across states
Tests
pnpm test:unit -- Ratingpasses locally.Related issue
Fixes #34202