Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[General] [Removed] - remove accessibilityComponentType and accessibilityTraits props (a11y) #24344

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions Libraries/Components/Touchable/TouchableWithoutFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,13 @@ const createReactClass = require('create-react-class');
const ensurePositiveDelayProps = require('ensurePositiveDelayProps');

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

import type {SyntheticEvent, LayoutEvent, PressEvent} from 'CoreEventTypes';
import type {EdgeInsetsProp} from 'EdgeInsetsPropType';
import type {
AccessibilityComponentType,
AccessibilityRole,
AccessibilityStates,
AccessibilityTraits,
} from 'ViewAccessibility';
import type {AccessibilityRole, AccessibilityStates} from 'ViewAccessibility';

type TargetEvent = SyntheticEvent<
$ReadOnly<{|
Expand All @@ -47,13 +40,11 @@ type FocusEvent = TargetEvent;
const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};

const OVERRIDE_PROPS = [
'accessibilityComponentType',
'accessibilityLabel',
'accessibilityHint',
'accessibilityIgnoresInvertColors',
'accessibilityRole',
'accessibilityStates',
'accessibilityTraits',
'hitSlop',
'nativeID',
'onBlur',
Expand All @@ -64,13 +55,11 @@ const OVERRIDE_PROPS = [

export type Props = $ReadOnly<{|
accessible?: ?boolean,
accessibilityComponentType?: ?AccessibilityComponentType,
accessibilityLabel?: ?Stringish,
accessibilityHint?: ?Stringish,
accessibilityIgnoresInvertColors?: ?boolean,
accessibilityRole?: ?AccessibilityRole,
accessibilityStates?: ?AccessibilityStates,
accessibilityTraits?: ?AccessibilityTraits,
children?: ?React.Node,
delayLongPress?: ?number,
delayPressIn?: ?number,
Expand Down Expand Up @@ -105,18 +94,11 @@ const TouchableWithoutFeedback = ((createReactClass({
accessible: PropTypes.bool,
accessibilityLabel: PropTypes.node,
accessibilityHint: PropTypes.string,
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)),
]),
/**
* When `accessible` is true (which is the default) this may be called when
* the OS-specific concept of "focus" occurs. Some platforms may not have
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 @@ -19,11 +19,9 @@ ReactNativeViewAttributes.UIView = {
accessible: true,
accessibilityActions: true,
accessibilityLabel: true,
accessibilityComponentType: true,
accessibilityLiveRegion: true,
accessibilityRole: true,
accessibilityStates: true,
accessibilityTraits: true,
accessibilityHint: true,
importantForAccessibility: true,
nativeID: 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 @@ -10,35 +10,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
32 changes: 1 addition & 31 deletions Libraries/Components/View/ViewPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ import type {EdgeInsetsProp} from 'EdgeInsetsPropType';
import type React from 'React';
import type {ViewStyleProp} from 'StyleSheet';
import type {TVViewProps} from 'TVViewPropTypes';
import type {
AccessibilityComponentType,
AccessibilityTrait,
AccessibilityRole,
AccessibilityStates,
} from 'ViewAccessibility';
import type {AccessibilityRole, AccessibilityStates} from 'ViewAccessibility';

export type ViewLayout = Layout;
export type ViewLayoutEvent = LayoutEvent;
Expand Down Expand Up @@ -254,16 +249,6 @@ type AndroidViewProps = $ReadOnly<{|
*/
needsOffscreenAlphaCompositing?: ?boolean,

/**
* 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?: ?AccessibilityComponentType,

/**
* Indicates to accessibility services whether the user should be notified
* when this view changes. Works for Android API >= 19 only.
Expand Down Expand Up @@ -336,21 +321,6 @@ type IOSViewProps = $ReadOnly<{|
*/
accessibilityIgnoresInvertColors?: ?boolean,

/**
* 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?: ?(
| AccessibilityTrait
| $ReadOnlyArray<AccessibilityTrait>
),

/**
* 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 @@ -69,18 +67,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 @@ -118,21 +104,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
7 changes: 1 addition & 6 deletions Libraries/Text/TextProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
import type {LayoutEvent, PressEvent, TextLayoutEvent} from 'CoreEventTypes';
import type React from 'React';
import type {TextStyleProp} from 'StyleSheet';
import type {
AccessibilityRole,
AccessibilityStates,
AccessibilityTrait,
} from 'ViewAccessibility';
import type {AccessibilityRole, AccessibilityStates} from 'ViewAccessibility';

export type PressRetentionOffset = $ReadOnly<{|
top: number,
Expand All @@ -40,7 +36,6 @@ export type TextProps = $ReadOnly<{|
accessibilityLabel?: ?Stringish,
accessibilityRole?: ?AccessibilityRole,
accessibilityStates?: ?AccessibilityStates,
accessibilityTraits?: ?(AccessibilityTrait | Array<AccessibilityTrait>),

/**
* Whether font should be scaled down automatically.
Expand Down
11 changes: 0 additions & 11 deletions React/Views/RCTViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ - (RCTShadowView *)shadowView
RCT_REMAP_VIEW_PROPERTY(accessibilityActions, reactAccessibilityElement.accessibilityActions, NSArray<NSString *>)
RCT_REMAP_VIEW_PROPERTY(accessibilityLabel, reactAccessibilityElement.accessibilityLabel, NSString)
RCT_REMAP_VIEW_PROPERTY(accessibilityHint, reactAccessibilityElement.accessibilityHint, NSString)
RCT_REMAP_VIEW_PROPERTY(accessibilityTraits, reactAccessibilityElement.accessibilityTraits, UIAccessibilityTraits)
RCT_REMAP_VIEW_PROPERTY(accessibilityViewIsModal, reactAccessibilityElement.accessibilityViewIsModal, BOOL)
RCT_REMAP_VIEW_PROPERTY(accessibilityElementsHidden, reactAccessibilityElement.accessibilityElementsHidden, BOOL)
RCT_REMAP_VIEW_PROPERTY(accessibilityIgnoresInvertColors, reactAccessibilityElement.shouldAccessibilityIgnoresInvertColors, BOOL)
Expand Down Expand Up @@ -159,16 +158,6 @@ - (RCTShadowView *)shadowView
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(nativeID, NSString *, RCTView)
{
view.nativeID = json ? [RCTConvert NSString:json] : defaultView.nativeID;
Expand Down

This file was deleted.

Loading