Skip to content

Commit

Permalink
Adds accessibility actions on Picker component
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Urtubia committed May 15, 2021
1 parent 492e5d2 commit 26a708b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Libraries/Components/Picker/Picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ import UnimplementedView from '../UnimplementedViews/UnimplementedView';

import type {TextStyleProp, ColorValue} from '../../StyleSheet/StyleSheet';

import type {
AccessibilityActionEvent,
AccessibilityActionInfo,
} from '../View/ViewAccessibility';

const MODE_DIALOG = 'dialog';
const MODE_DROPDOWN = 'dropdown';

Expand Down Expand Up @@ -115,6 +120,10 @@ type PickerProps = $ReadOnly<{|
* The string used for the accessibility label. Will be read once focused on the picker but not on change.
*/
accessibilityLabel?: ?string,

accessible?: ?boolean,
accessibilityActions?: ?$ReadOnlyArray<AccessibilityActionInfo>,
onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed,
|}>;

/**
Expand Down
11 changes: 11 additions & 0 deletions Libraries/Components/Picker/PickerAndroid.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ import StyleSheet from '../../StyleSheet/StyleSheet';
import invariant from 'invariant';
import processColor from '../../StyleSheet/processColor';

import type {
AccessibilityActionEvent,
AccessibilityActionInfo,
} from '../View/ViewAccessibility';

import type {SyntheticEvent} from '../../Types/CoreEventTypes';
import type {ColorValue, TextStyleProp} from '../../StyleSheet/StyleSheet';

Expand All @@ -31,6 +36,9 @@ type PickerItemSelectSyntheticEvent = SyntheticEvent<
type PickerItemValue = number | string;

type Props = $ReadOnly<{|
accessible?: ?boolean,
accessibilityActions?: ?$ReadOnlyArray<AccessibilityActionInfo>,
onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed,
accessibilityLabel?: ?Stringish,
children?: React.Node,
style?: ?TextStyleProp,
Expand Down Expand Up @@ -111,6 +119,9 @@ function PickerAndroid(props: Props): React.Node {
);

const rootProps = {
accessible: props.accessible,
accessibilityActions: props.accessibilityActions,
onAccessibilityAction: props.onAccessibilityAction,
accessibilityLabel: props.accessibilityLabel,
enabled: props.enabled,
items,
Expand Down

0 comments on commit 26a708b

Please sign in to comment.