Skip to content

Commit

Permalink
Added in Prop for CurrentViewState
Browse files Browse the repository at this point in the history
Summary:
Added in a prop for CurrentViewState that is used to set the state of the current view for both accessibility and regular view settings..

Ex:
AccessibilityRole = "button"
CurrentViewState = ['selected']

This will trigger talk back/voiceover to announce both the role and the state.

Unlike Accessibility Role, Accessibility States can take on more than one form, and are passed in an array.
Ex: AccessibilityState = ['selected', 'disabled']

Currently, two options are available: selected and disabled

Reviewed By: PeteTheHeat

Differential Revision: D8837848

fbshipit-source-id: ca30c950a2aa713813be8577ea4fa9ba9bfc698a
  • Loading branch information
Ziqi Chen authored and facebook-github-bot committed Jul 17, 2018
1 parent d9eeae9 commit 3cfa7ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Libraries/Components/View/ViewAccessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ export type AccessibilityRole =
| 'adjustable'
| 'imagebutton';

export type CurrentViewState = 'selected' | 'disabled';

export type CurrentViewStates =
| CurrentViewState
| $ReadOnlyArray<CurrentViewState>;

module.exports = {
AccessibilityTraits: [
'none',
Expand Down Expand Up @@ -87,4 +93,5 @@ module.exports = {
'adjustable',
'imagebutton',
],
CurrentViewStates: ['selected', 'disabled'],
};
8 changes: 7 additions & 1 deletion Libraries/Components/View/ViewPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ const {
AccessibilityComponentTypes,
AccessibilityTraits,
AccessibilityRoles,
CurrentViewStates,
} = require('ViewAccessibility');

import type {
AccessibilityComponentType,
AccessibilityTrait,
AccessibilityRole,
CurrentViewState,
} from 'ViewAccessibility';
import type {EdgeInsetsProp} from 'EdgeInsetsPropType';
import type {TVViewProps} from 'TVViewPropTypes';
Expand Down Expand Up @@ -92,6 +94,7 @@ export type ViewProps = $ReadOnly<{|
accessibilityIgnoresInvertColors?: boolean,
accessibilityTraits?: AccessibilityTrait | Array<AccessibilityTrait>,
accessibilityRole?: AccessibilityRole,
currentViewStates?: Array<CurrentViewState>,
accessibilityViewIsModal?: boolean,
accessibilityElementsHidden?: boolean,
children?: ?React.Node,
Expand Down Expand Up @@ -144,10 +147,13 @@ module.exports = {

/**
* Indicates to accessibility services to treat UI component like a
* native one. Merging accessibilityComponentType and accessibilityTraits.
*/
accessibilityRole: PropTypes.oneOf(AccessibilityRoles),

/**
* Indicates to accessibility services that UI Component is in a specific State.
*/
currentViewStates: PropTypes.arrayOf(PropTypes.oneOf(CurrentViewStates)),
/**
* Indicates to accessibility services whether the user should be notified
* when this view changes. Works for Android API >= 19 only.
Expand Down

0 comments on commit 3cfa7ae

Please sign in to comment.