mirror of
https://github.com/status-im/react-native.git
synced 2025-01-11 10:06:31 +00:00
121e2e5ca6
Summary: Previously, I created two props, `accessibilityRole` and `accessibilityStates` for view. These props were intended to be a cross-platform solution to replace `accessibilityComponentType` on Android and `accessibilityTraits` on iOS. In this stack, I ran a code mod to replace instances of the two old properties used in our codebase with the new ones. For this diff, I did a search for all the remnant uses of `accessibilityComponentType` that was not caught by my script, and I manually changed them to `accessibilityRole` and `accessibilityStates`. If the same prop also set `accessibilityTraits` I also removed that here because the two new props works on both platforms. It was difficult to write a script for this, because most of them were contextual changes. Out of the contextual changes, most of them followed one of these two patterns: Before: ``` const accessibilityComponentType = 'button'; const accessibilityTraits = ['button']; if (this.props.checked) { accessibilityTraits.push('selected'); } if (this.props.disabled) { accessibilityTraits.push('disabled'); } contentView = ( <AdsManagerTouchableHighlight accessibilityComponentType={accessibilityComponentType} accessibilityTraits={accessibilityTraits} ``` After: const accessibilityRole = 'button'; const accessibilityStates = []; if (this.props.checked) { accessibilityStates.push('selected'); } if (this.props.disabled) { accessibilityStates.push('disabled'); } contentView = ( <AdsManagerTouchableHighlight accessibilityRole={accessibilityRole} accessibilityStates={accessibilityStates} Before: ``` <PressableBackground accessible={this.props.accessible} accessibilityLabel={this.props.accessibilityLabel} accessibilityTraits={this.props.accessibilityTraits} ``` After: ``` <PressableBackground accessible={this.props.accessible} accessibilityLabel={this.props.accessibilityLabel} accessibilityRole={this.props.accessibilityRole} accessibilityRole={this.props.accessibilityStates} ``` In addition to changing the props on the components, Another fix I had to do was to add props accessibilityRole and accessibilityStates to components that don't directly inherit properties from view including text input and touchables. Reviewed By: PeteTheHeat Differential Revision: D8943499 fbshipit-source-id: fbb40a5e5f5d630b0fe56a009ff24635d4c8cc93