Skip to content

Commit

Permalink
f70e58f|Facebook Github Bot|- remove accessibilityComponentType and a…
Browse files Browse the repository at this point in the history
…ccessibilityTraits props (a11y) (facebook#24344)
  • Loading branch information
williamdeng committed Apr 20, 2020
1 parent d63ec16 commit 429ab0d
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 354 deletions.
19 changes: 2 additions & 17 deletions Libraries/Components/Touchable/TouchableWithoutFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,19 @@ const createReactClass = require('create-react-class');
const ensurePositiveDelayProps = require('ensurePositiveDelayProps');

const {
DeprecatedAccessibilityComponentTypes,
DeprecatedAccessibilityRoles,
DeprecatedAccessibilityStates,
DeprecatedAccessibilityTraits,
} = require('DeprecatedViewAccessibility');

export type Event = Object;

import type {EdgeInsetsProp} from 'EdgeInsetsPropType';
import type {
AccessibilityComponentType,
AccessibilityRole,
AccessibilityStates,
AccessibilityTraits,
} from 'ViewAccessibility';
import type {AccessibilityRole, AccessibilityStates} from 'ViewAccessibility';

const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};

export type Props = $ReadOnly<{|
accessible?: ?boolean,
accessibilityComponentType?: ?AccessibilityComponentType,
accessibilityLabel?:
| null
| React$PropType$Primitive<any>
Expand All @@ -51,7 +43,6 @@ export type Props = $ReadOnly<{|
accessibilityIgnoresInvertColors?: ?boolean,
accessibilityRole?: ?AccessibilityRole,
accessibilityStates?: ?AccessibilityStates,
accessibilityTraits?: ?AccessibilityTraits,
children?: ?React.Node,
delayLongPress?: ?number,
delayPressIn?: ?number,
Expand Down Expand Up @@ -83,17 +74,11 @@ const TouchableWithoutFeedback = ((createReactClass({
propTypes: {
accessible: PropTypes.bool,
accessibilityLabel: PropTypes.node,
accessibilityComponentType: PropTypes.oneOf(
DeprecatedAccessibilityComponentTypes,
),
accessibilityIgnoresInvertColors: PropTypes.bool,
accessibilityRole: PropTypes.oneOf(DeprecatedAccessibilityRoles),
accessibilityStates: PropTypes.arrayOf(
PropTypes.oneOf(DeprecatedAccessibilityStates),
),
accessibilityTraits: PropTypes.oneOfType([
PropTypes.oneOf(DeprecatedAccessibilityTraits),
PropTypes.arrayOf(PropTypes.oneOf(DeprecatedAccessibilityTraits)),
]),
/**
* If true, disable all interactions for this component.
*/
Expand Down
2 changes: 0 additions & 2 deletions Libraries/Components/View/ReactNativeViewAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ ReactNativeViewAttributes.UIView = {
accessible: true,
accessibilityActions: true,
accessibilityLabel: true,
accessibilityComponentType: true,
accessibilityLiveRegion: true,
accessibilityRole: true,
accessibilityStates: true,
accessibilityTraits: true,
importantForAccessibility: true,
nativeID: true,
testID: true,
Expand Down
29 changes: 0 additions & 29 deletions Libraries/Components/View/ViewAccessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,6 @@
*/
'use strict';

export type AccessibilityTrait =
| 'none'
| 'button'
| 'link'
| 'header'
| 'search'
| 'image'
| 'selected'
| 'plays'
| 'key'
| 'text'
| 'summary'
| 'disabled'
| 'frequentUpdates'
| 'startsMedia'
| 'adjustable'
| 'allowsDirectInteraction'
| 'pageTurn';

export type AccessibilityTraits =
| AccessibilityTrait
| $ReadOnlyArray<AccessibilityTrait>;

export type AccessibilityComponentType =
| 'none'
| 'button'
| 'radiobutton_checked'
| 'radiobutton_unchecked';

// This must be kept in sync with the AccessibilityRolesMask in RCTViewManager.m
export type AccessibilityRole =
| 'none'
Expand Down
86 changes: 9 additions & 77 deletions Libraries/Components/View/ViewPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,11 @@ const StyleSheetPropType = require('StyleSheetPropType');
const ViewStylePropTypes = require('ViewStylePropTypes');

const {
AccessibilityComponentTypes,
AccessibilityTraits,
AccessibilityRoles,
AccessibilityStates,
} = require('ViewAccessibility');

import type {
AccessibilityComponentType,
AccessibilityTrait,
AccessibilityRole,
AccessibilityState,
} from 'ViewAccessibility';
DeprecatedAccessibilityRoles,
DeprecatedAccessibilityStates,
} = require('DeprecatedViewAccessibility');

import type {AccessibilityRole, AccessibilityStates} from 'ViewAccessibility';
import type {EdgeInsetsProp} from 'EdgeInsetsPropType';
import type {TVViewProps} from 'TVViewPropTypes';

Expand Down Expand Up @@ -58,13 +51,11 @@ export type ViewProps = {
| Array<any>
| any,
accessibilityActions?: Array<string>,
accessibilityComponentType?: AccessibilityComponentType,
accessibilityLiveRegion?: 'none' | 'polite' | 'assertive',
importantForAccessibility?: 'auto'| 'yes'| 'no'| 'no-hide-descendants',
accessibilityIgnoresInvertColors?: boolean,
accessibilityTraits?: AccessibilityTrait | Array<AccessibilityTrait>,
accessibilityRole?: AccessibilityRole,
accessibilityStates?: Array<AccessibilityState>,
accessibilityRole?: ?AccessibilityRole,
accessibilityStates?: ?AccessibilityStates,
accessibilityViewIsModal?: bool,
onAccessibilityAction?: Function,
onAccessibilityTap?: Function,
Expand Down Expand Up @@ -122,38 +113,15 @@ module.exports = {
*/
accessibilityIgnoresInvertColors: PropTypes.bool,

/**
* Indicates to accessibility services to treat UI component like a
* native one. Works for Android only.
*
* Possible values are one of:
*
* - `'none'`
* - `'button'`
* - `'checkbox'`
* - `'radiobutton'`
* - `'switch'`
* - `'checked'`
* - `'disabled'`
* - `'radiobutton_checked'` (deprecated)
* - `'radiobutton_unchecked'` (deprecated)
*
* @platform android
*/
accessibilityComponentType: PropTypes.oneOfType([
PropTypes.oneOf(AccessibilityComponentTypes),
PropTypes.arrayOf(PropTypes.oneOf(AccessibilityComponentTypes)),
]),

/**
* Indicates to accessibility services to treat UI component like a specific role.
*/
accessibilityRole: PropTypes.oneOf(AccessibilityRoles),
accessibilityRole: PropTypes.oneOf(DeprecatedAccessibilityRoles),

/**
* Indicates to accessibility services that UI Component is in a specific State.
*/
accessibilityStates: PropTypes.arrayOf(PropTypes.oneOf(AccessibilityStates)),
accessibilityStates: PropTypes.arrayOf(PropTypes.oneOf(DeprecatedAccessibilityStates)),

/**
* Indicates to accessibility services whether the user should be notified
Expand Down Expand Up @@ -201,42 +169,6 @@ module.exports = {
'no-hide-descendants',
]),

/**
* Provides additional traits to screen reader. By default no traits are
* provided unless specified otherwise in element.
*
* You can provide one trait or an array of many traits.
*
* Possible values for `AccessibilityTraits` are:
*
* - `'none'` - The element has no traits.
* - `'button'` - The element should be treated as a button.
* - `'link'` - The element should be treated as a link.
* - `'header'` - The element is a header that divides content into sections.
* - `'search'` - The element should be treated as a search field.
* - `'image'` - The element should be treated as an image.
* - `'selected'` - The element is selected.
* - `'plays'` - The element plays sound.
* - `'key'` - The element should be treated like a keyboard key.
* - `'text'` - The element should be treated as text.
* - `'summary'` - The element provides app summary information.
* - `'disabled'` - The element is disabled.
* - `'frequentUpdates'` - The element frequently changes its value.
* - `'startsMedia'` - The element starts a media session.
* - `'adjustable'` - The element allows adjustment over a range of values.
* - `'allowsDirectInteraction'` - The element allows direct touch interaction for VoiceOver users.
* - `'pageTurn'` - Informs VoiceOver that it should scroll to the next page when it finishes reading the contents of the element.
*
* See the [Accessibility guide](docs/accessibility.html#accessibilitytraits-ios)
* for more information.
*
* @platform ios
*/
accessibilityTraits: PropTypes.oneOfType([
PropTypes.oneOf(AccessibilityTraits),
PropTypes.arrayOf(PropTypes.oneOf(AccessibilityTraits)),
]),

/**
* A value indicating whether VoiceOver should ignore the elements
* within views that are siblings of the receiver.
Expand Down
25 changes: 0 additions & 25 deletions Libraries/DeprecatedPropTypes/DeprecatedViewAccessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,6 @@
'use strict';

module.exports = {
DeprecatedAccessibilityTraits: [
'none',
'button',
'link',
'header',
'search',
'image',
'selected',
'plays',
'key',
'text',
'summary',
'disabled',
'frequentUpdates',
'startsMedia',
'adjustable',
'allowsDirectInteraction',
'pageTurn',
],
DeprecatedAccessibilityComponentTypes: [
'none',
'button',
'radiobutton_checked',
'radiobutton_unchecked',
],
// This must be kept in sync with the AccessibilityRolesMask in RCTViewManager.m
DeprecatedAccessibilityRoles: [
'none',
Expand Down
29 changes: 0 additions & 29 deletions Libraries/DeprecatedPropTypes/DeprecatedViewPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ const DeprecatedStyleSheetPropType = require('DeprecatedStyleSheetPropType');
const DeprecatedViewStylePropTypes = require('DeprecatedViewStylePropTypes');

const {
DeprecatedAccessibilityComponentTypes,
DeprecatedAccessibilityTraits,
DeprecatedAccessibilityRoles,
DeprecatedAccessibilityStates,
} = require('DeprecatedViewAccessibility');
Expand Down Expand Up @@ -59,18 +57,6 @@ module.exports = {
*/
accessibilityIgnoresInvertColors: PropTypes.bool,

/**
* Indicates to accessibility services to treat UI component like a
* native one. Works for Android only.
*
* @platform android
*
* See http://facebook.github.io/react-native/docs/view.html#accessibilitycomponenttype
*/
accessibilityComponentType: PropTypes.oneOf(
DeprecatedAccessibilityComponentTypes,
),

/**
* Indicates to accessibility services to treat UI component like a specific role.
*/
Expand Down Expand Up @@ -108,21 +94,6 @@ module.exports = {
'no-hide-descendants',
]),

/**
* Provides additional traits to screen reader. By default no traits are
* provided unless specified otherwise in element.
*
* You can provide one trait or an array of many traits.
*
* @platform ios
*
* See http://facebook.github.io/react-native/docs/view.html#accessibilitytraits
*/
accessibilityTraits: PropTypes.oneOfType([
PropTypes.oneOf(DeprecatedAccessibilityTraits),
PropTypes.arrayOf(PropTypes.oneOf(DeprecatedAccessibilityTraits)),
]),

/**
* A value indicating whether VoiceOver should ignore the elements
* within views that are siblings of the receiver.
Expand Down
11 changes: 0 additions & 11 deletions React/Views/RCTViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ - (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(__unused NSDictio
RCT_REMAP_VIEW_PROPERTY(accessible, reactAccessibilityElement.isAccessibilityElement, BOOL)
RCT_REMAP_VIEW_PROPERTY(accessibilityActions, reactAccessibilityElement.accessibilityActions, NSString)
RCT_REMAP_VIEW_PROPERTY(accessibilityLabel, reactAccessibilityElement.accessibilityLabel, NSString)
RCT_REMAP_VIEW_PROPERTY(accessibilityTraits, reactAccessibilityElement.accessibilityTraits, UIAccessibilityTraits)
RCT_REMAP_VIEW_PROPERTY(accessibilityViewIsModal, reactAccessibilityElement.accessibilityViewIsModal, BOOL)
RCT_REMAP_VIEW_PROPERTY(accessibilityIgnoresInvertColors, reactAccessibilityElement.shouldAccessibilityIgnoresInvertColors, BOOL)
RCT_REMAP_VIEW_PROPERTY(onAccessibilityAction, reactAccessibilityElement.onAccessibilityAction, RCTDirectEventBlock)
Expand Down Expand Up @@ -169,16 +168,6 @@ - (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(__unused NSDictio
view.reactAccessibilityElement.accessibilityTraits = (view.reactAccessibilityElement.accessibilityTraits & ~AccessibilityRolesMask) | maskedTraits;
}

RCT_CUSTOM_VIEW_PROPERTY(accessibilityStates, UIAccessibilityTraits, RCTView)
{
// This mask must be kept in sync with the AccessibilityStates enum defined in ViewAccessibility.js and DeprecatedViewAccessibility.js
const UIAccessibilityTraits AccessibilityStatesMask = UIAccessibilityTraitNotEnabled | UIAccessibilityTraitSelected;

UIAccessibilityTraits newTraits = json ? [RCTConvert UIAccessibilityTraits:json] : defaultView.accessibilityTraits;
UIAccessibilityTraits maskedTraits = newTraits & AccessibilityStatesMask;
view.reactAccessibilityElement.accessibilityTraits = (view.reactAccessibilityElement.accessibilityTraits & ~AccessibilityStatesMask) | maskedTraits;
}

RCT_CUSTOM_VIEW_PROPERTY(pointerEvents, RCTPointerEvents, RCTView)
{
if ([view respondsToSelector:@selector(setPointerEvents:)]) {
Expand Down
Loading

0 comments on commit 429ab0d

Please sign in to comment.