-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
accessibilityTraits + accessibilityComponentType >> accessibilityRole…
… + accessibilityStates 2/3 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
- Loading branch information
1 parent
50e4001
commit 121e2e5
Showing
9 changed files
with
24 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters