Skip to content

Commit 36672c3

Browse files
alvinmatias69facebook-github-bot
authored andcommitted
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 [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
1 parent d3ac9fa commit 36672c3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Libraries/Components/Switch/Switch.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class Switch extends React.Component<Props> {
156156
<AndroidSwitchNativeComponent
157157
{...props}
158158
{...platformProps}
159-
accessibilityRole={props.accessibilityRole ?? 'button'}
159+
accessibilityRole={props.accessibilityRole ?? 'switch'}
160160
onChange={this._handleChange}
161161
onResponderTerminationRequest={returnsFalse}
162162
onStartShouldSetResponder={returnsTrue}
@@ -189,7 +189,7 @@ class Switch extends React.Component<Props> {
189189
<SwitchNativeComponent
190190
{...props}
191191
{...platformProps}
192-
accessibilityRole={props.accessibilityRole ?? 'button'}
192+
accessibilityRole={props.accessibilityRole ?? 'switch'}
193193
onChange={this._handleChange}
194194
onResponderTerminationRequest={returnsFalse}
195195
onStartShouldSetResponder={returnsTrue}

0 commit comments

Comments
 (0)