-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[base-ui][Switch] Add missing role attribute #40907
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
Conversation
Netlify deploy previewhttps://deploy-preview-40907--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
| getSlotProps: getInputProps, | ||
| externalSlotProps: slotProps.input, | ||
| additionalProps: { | ||
| role: 'switch', // Switch component should have the role "switch" to meet a11y guidelines |
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 should be applied directly in the JSX component, no?
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.
I tried adding the prop into useSwitch.getInputProps but useSwitch is being used by Radio, CheckBox along with Switch component. So, added it in additionalProps
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 should be returned by the hook.
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.
useSwitch hook is being consumed by Radio and Checkbox components, along with the Switch component. Adding role = switch to the hook returned value breaks those components. To make the hook work, we might have send another parameter to useSwitch, which I felt isnt an ideal solution. We have additionalProps, which came handy for the fix.
But, I'm open for suggestions.
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.
useSwitch hook is being consumed by Radio and Checkbox components,
This is a bit unfortunate (and temporary). I'd make the hook return the correct set of props for the Switch and override them if needed in Checkbox and Radio button.
We are going to add Checkbox and Radio Button to Base UI in the next batch of components (likely late Q2 or Q3 this year), so it won't be an issue anymore.
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.
Got it, thanks for the update @michaldudak! Made changes as per the discussion
Co-authored-by: Michał Dudak <[email protected]> Signed-off-by: Kirankumar Ambati <[email protected]>
Co-authored-by: Michał Dudak <[email protected]> Signed-off-by: Kirankumar Ambati <[email protected]>
|
@michaldudak the build step |
|
@michaldudak Triggered an empty build and pipeline is green now :) |
michaldudak
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.
Looks good! Please write a summary of changes in the description of this PR so it's easier to find in the future.
Done @michaldudak 👍 |
|
Thanks for your contribution! |
Related to #40615
Changes in this PR:
Added the missing accessibility features for the
Switchcomponent anduseSwitchhook:roleshould beswitcharia-checkedattribute