-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
[Switch] added role to Span element #46318
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
Hey @siriwatknp, please can you review this PR. If anything needs to be added, please let me know, I will update the PR. Thanks! |
@@ -206,7 +206,7 @@ const SwitchBase = React.forwardRef(function SwitchBase(props, ref) { | |||
centerRipple: true, | |||
focusRipple: !disableFocusRipple, | |||
disabled, | |||
role: undefined, | |||
role: 'switch', |
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 think the explicit role: undefined
exist for specific fix.
The proper fix is to add role: 'switch'
to Switch
component. @sai6855 Would you mind checking on this?
This PR requires a test to ensure that the issue is fixed without introducing any regression.
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.
AFAIU, SwitchBase
component uses ButtonBase
as the root component, which automatically assigns role=button
to Switch
. So, to override that, we explicitly provide role=undefined
as a prop.
But in our case, we want the role
to be switch
. So, I feel that updating SwitchBase
role to switch
is the right approach. But, it's just my thought process and I can be wrong.
Fixes #45436