Switch: Improve Accessibility

Summary: On Android, `Switch` does not currently read its role as a "button". This fixes that and makes it consistent with iOS.

Reviewed By: sahrens

Differential Revision: D13136253

fbshipit-source-id: 0de5d54772d204168138cb2af7815cc458f72682
This commit is contained in:
Tim Yung
2018-11-27 09:42:32 -08:00
committed by Facebook Github Bot
parent 2ae559a2a4
commit 0c8db08f51

View File

@@ -164,6 +164,7 @@ class Switch extends React.Component<Props> {
<SwitchNativeComponent
{...props}
{...platformProps}
accessibilityRole={props.accessibilityRole ?? 'button'}
onChange={this._handleChange}
onResponderTerminationRequest={returnsFalse}
onStartShouldSetResponder={returnsTrue}