Skip to content
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

role="switch" should map to element <button> #2645

Closed
1 task done
dukenv0307 opened this issue Mar 3, 2024 · 2 comments
Closed
1 task done

role="switch" should map to element <button> #2645

dukenv0307 opened this issue Mar 3, 2024 · 2 comments
Labels

Comments

@dukenv0307
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

role="switch" should both map to HTML element button .
Here's official web standard doc on the switch role: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/switch_role, it uses the button HTML element (also here). Another doc of button HTML element, with switch in Permitted ARIA roles.

Expected behavior

It should be on the web

Steps to reproduce

  1. Create a View component
  2. Add role="switch" prop to this View

Test case

https://codesandbox.io/p/sandbox/swtich-role-5qjrcy

Additional comments

Solution

We should map the switch role to button html element in react-native-web here by this one line change:

switch: 'button'

@dukenv0307 dukenv0307 added the bug label Mar 3, 2024
@dukenv0307 dukenv0307 changed the title role="search" should map to element <button> role="switch" should map to element <button> Mar 3, 2024
@necolas
Copy link
Owner

necolas commented Mar 3, 2024

switch can be used with non-button elements too, like div and input[type=checkbox]

@necolas necolas closed this as completed Mar 3, 2024
@dukenv0307
Copy link
Author

@necolas Currently I want to customize mapping role="switch" to button element in my code. Can I define somewhere or pass in some props?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants