Skip to content
Permalink
Browse files
Fix Switch component accessibility role (#26899)
Summary:
`accessibilityRole` communicates the purpose of a component to the user of assistive technology. It needs to have the correct value for it to be fully utilized.

Switch component has `accessibilityRole` of a `button` instead of `switch` on default. Change the component default role to `switch`.

## Changelog

[General] [Fixed] - Change default `accessibilityRole` of Switch component from `button` to `switch`
Pull Request resolved: #26899

Test Plan:
- All unit test passed
- On Switch component, it's supposed to have `switch` like element type on both platform. (`XCUIElementTypeSwitch` on iOS)

fix [#26873

Reviewed By: yungsters

Differential Revision: D18002755

Pulled By: mdvacca

fbshipit-source-id: 60446f94b23f8355f954805fb4dc08c89d08e492
  • Loading branch information
alvinmatias69 authored and facebook-github-bot committed Oct 19, 2019
1 parent d3ac9fa commit 36672c3851a044a1ab0edcfaa2790c02f7909695
Showing 1 changed file with 2 additions and 2 deletions.
@@ -156,7 +156,7 @@ class Switch extends React.Component<Props> {
<AndroidSwitchNativeComponent
{...props}
{...platformProps}
accessibilityRole={props.accessibilityRole ?? 'button'}
accessibilityRole={props.accessibilityRole ?? 'switch'}
onChange={this._handleChange}
onResponderTerminationRequest={returnsFalse}
onStartShouldSetResponder={returnsTrue}
@@ -189,7 +189,7 @@ class Switch extends React.Component<Props> {
<SwitchNativeComponent
{...props}
{...platformProps}
accessibilityRole={props.accessibilityRole ?? 'button'}
accessibilityRole={props.accessibilityRole ?? 'switch'}
onChange={this._handleChange}
onResponderTerminationRequest={returnsFalse}
onStartShouldSetResponder={returnsTrue}

0 comments on commit 36672c3

Please sign in to comment.