-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: expose input styling on RAC Checkbox and Radio #10517
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
Open
gonzoblasco
wants to merge
3
commits into
adobe:main
Choose a base branch
from
gonzoblasco:fix/checkbox-radio-sr-focus-indicator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
393b02c
fix: expose input and VisuallyHidden styling on RAC Checkbox and Radio
gonzoblasco 3d19d3e
Merge branch 'main' into fix/checkbox-radio-sr-focus-indicator
gonzoblasco 182d451
feat: add stories for screen reader focus ring on Checkbox and Radio
gonzoblasco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
VisuallyHidden has highly specific styles right now that ensure it's visible to screen readers. If we expose all of these styles, it'd be pretty easy for people to accidentally make it not accessible.
For example, making it full width and height would probably show the native browser chrome for the input. The natural thing to do is then to use visibility hidden. This is not accessible.
Please include a story that you, the person, confirm this works on. Including screen readers. Once we have that maybe we can find some smaller API to expose, as we do not want to expose all of these props if possible.
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.
You're right that exposing raw control over
VisuallyHiddengives people a lot of rope, and thevisibility: hiddentrap is a real one - it is the natural thing to reach for and it does break screen reader exposure.Two things I'd like to do:
Add a story and validate it with a real screen reader. I'll add a story for Checkbox and Radio that stretches the hidden input over the component using the documented technique (
visuallyHiddenStyle={{inset: 0, width: 'auto', height: 'auto'}}+inputStyle={{position: 'absolute', inset: 0}}), and confirm with VoiceOver that the focus ring tracks the component and the input stays exposed.Propose a smaller API. Instead of exposing all four props (
inputClassName/inputStyle+visuallyHiddenClassName/visuallyHiddenStyle), I'd rather explore a single prop that encodes the safe pattern and keepsVisuallyHiddenencapsulated. Something like afocusRingorinputPositionboolean that applies the correct positioning internally (label as containing block, wrapper stretched, input filling it) without handing out arbitrary style/className access. That achieves the fix for the reported issue with a much smaller surface, and it cannot be used to accidentally un-accessible the component.My instinct is option 2 is the right shape for a library like this - the reported issue is specifically about the screen reader focus ring not tracking the component, and a boolean that encodes "make the hidden input cover the component" solves exactly that without exposing implementation details.
Want me to put together a proposal for the smaller prop (with the story + VoiceOver check) so we can compare it side by side against the current approach?
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.
yes, let's explore a smaller api