Skip to content

Commit

Permalink
Fix Switch component accessibility role (#26899)
Browse files Browse the repository at this point in the history
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 [https://github.com/facebook/react-native/issues/26873](https://github.com/facebook/react-native/issues/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 36672c3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Libraries/Components/Switch/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 36672c3

Please sign in to comment.