Skip to content

Commit 174ebb3

Browse files
committed
[change] Remove deprecated accessibility APIs
Removes 'accessible', 'accessibilityState', and 'accessibilityValue' props.
1 parent 9583155 commit 174ebb3

File tree

15 files changed

+87
-346
lines changed

15 files changed

+87
-346
lines changed

packages/react-native-web/src/exports/ActivityIndicator/__tests__/index-test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
/* eslint-env jasmine, jest */
1+
/**
2+
* Copyright (c) Nicolas Gallagher.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
27

38
import ActivityIndicator from '..';
49
import React from 'react';

packages/react-native-web/src/exports/ActivityIndicator/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import * as React from 'react';
1414
import StyleSheet from '../StyleSheet';
1515
import View from '../View';
1616

17-
const accessibilityValue = { max: 1, min: 0 };
18-
1917
const createSvgCircle = (style) => (
2018
<circle cx="16" cy="16" fill="none" r="14" strokeWidth="4" style={style} />
2119
);
@@ -59,7 +57,8 @@ const ActivityIndicator: React.AbstractComponent<
5957
<View
6058
{...other}
6159
accessibilityRole="progressbar"
62-
accessibilityValue={accessibilityValue}
60+
accessibilityValueMax={1}
61+
accessibilityValueMin={0}
6362
ref={forwardedRef}
6463
style={[styles.container, style]}
6564
>

packages/react-native-web/src/exports/Modal/ModalContent.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ const ModalContent: React.AbstractComponent<
4747
}, [transparent]);
4848

4949
return (
50-
<View accessibilityRole={active ? 'dialog' : null} aria-modal ref={forwardedRef} style={style}>
50+
<View
51+
accessibilityModal={true}
52+
accessibilityRole={active ? 'dialog' : null}
53+
ref={forwardedRef}
54+
style={style}
55+
>
5156
<View style={styles.container}>{children}</View>
5257
</View>
5358
);

packages/react-native-web/src/exports/ProgressBar/index.js

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,24 @@ const ProgressBar: React.AbstractComponent<
3636
} = props;
3737

3838
const percentageProgress = progress * 100;
39-
40-
const progressRef = React.useRef(null);
41-
React.useEffect(() => {
42-
const width = indeterminate ? '25%' : `${percentageProgress}%`;
43-
if (progressRef.current != null) {
44-
progressRef.current.setNativeProps({
45-
style: { width }
46-
});
47-
}
48-
}, [indeterminate, percentageProgress, progressRef]);
39+
const width = indeterminate ? '25%' : `${percentageProgress}%`;
4940

5041
return (
5142
<View
5243
{...other}
5344
accessibilityRole="progressbar"
54-
accessibilityValue={{
55-
max: 100,
56-
min: 0,
57-
now: indeterminate ? null : percentageProgress
58-
}}
45+
accessibilityValueMax={100}
46+
accessibilityValueMin={0}
47+
accessibilityValueNow={indeterminate ? null : percentageProgress}
5948
ref={ref}
6049
style={[styles.track, style, { backgroundColor: trackColor }]}
6150
>
6251
<View
63-
ref={progressRef}
64-
style={[styles.progress, indeterminate && styles.animation, { backgroundColor: color }]}
52+
style={[
53+
{ backgroundColor: color, width },
54+
styles.progress,
55+
indeterminate && styles.animation
56+
]}
6557
/>
6658
</View>
6759
);

packages/react-native-web/src/exports/Text/types.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,6 @@ export type TextProps = {
7272
| 'listitem'
7373
| 'none'
7474
| 'text',
75-
accessibilityState?: {
76-
busy?: ?boolean,
77-
checked?: ?boolean | 'mixed',
78-
disabled?: ?boolean,
79-
expanded?: ?boolean,
80-
grabbed?: ?boolean,
81-
hidden?: ?boolean,
82-
invalid?: ?boolean,
83-
pressed?: ?boolean,
84-
readonly?: ?boolean,
85-
required?: ?boolean,
86-
selected?: ?boolean
87-
},
8875
dir?: 'auto' | 'ltr' | 'rtl',
8976
numberOfLines?: ?number,
9077
onPress?: (e: any) => void,

packages/react-native-web/src/exports/View/types.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -113,27 +113,8 @@ export type ViewStyle = {
113113

114114
export type ViewProps = {
115115
...AccessibilityProps,
116-
accessibilityState?: {
117-
busy?: ?boolean,
118-
checked?: ?boolean | 'mixed',
119-
disabled?: ?boolean,
120-
expanded?: ?boolean,
121-
grabbed?: ?boolean,
122-
hidden?: ?boolean,
123-
invalid?: ?boolean,
124-
modal?: ?boolean,
125-
pressed?: ?boolean,
126-
readonly?: ?boolean,
127-
required?: ?boolean,
128-
selected?: ?boolean
129-
},
130-
accessibilityValue?: {
131-
max?: ?number,
132-
min?: ?number,
133-
now?: ?number,
134-
text?: ?string
135-
},
136116
children?: ?any,
117+
dir?: 'ltr' | 'rtl',
137118
focusable?: ?boolean,
138119
nativeID?: ?string,
139120
onBlur?: (e: any) => void,

packages/react-native-web/src/modules/createDOMProps/__tests__/__snapshots__/index-test.js.snap

Lines changed: 0 additions & 49 deletions
This file was deleted.

packages/react-native-web/src/modules/createDOMProps/__tests__/index-test.js

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -118,43 +118,6 @@ describe('modules/createDOMProps', () => {
118118
expect(props.role).toEqual('button');
119119
});
120120

121-
describe('prop "accessibilityState"', () => {
122-
function createAccessibilityState(value) {
123-
return {
124-
busy: value,
125-
checked: value,
126-
disabled: value,
127-
expanded: value,
128-
grabbed: value,
129-
hidden: value,
130-
invalid: value,
131-
modal: value,
132-
pressed: value,
133-
readonly: value,
134-
required: value,
135-
selected: value
136-
};
137-
}
138-
139-
test('values are "undefined"', () => {
140-
const accessibilityState = createAccessibilityState(undefined);
141-
const props = createProps({ accessibilityState });
142-
expect(props).toMatchSnapshot();
143-
});
144-
145-
test('values are "false"', () => {
146-
const accessibilityState = createAccessibilityState(false);
147-
const props = createProps({ accessibilityState });
148-
expect(props).toMatchSnapshot();
149-
});
150-
151-
test('values are "true"', () => {
152-
const accessibilityState = createAccessibilityState(true);
153-
const props = createProps({ accessibilityState });
154-
expect(props).toMatchSnapshot();
155-
});
156-
});
157-
158121
test('prop "className" is preserved', () => {
159122
const className = 'external-class-name';
160123
const props = createProps({ className });
@@ -172,16 +135,4 @@ describe('modules/createDOMProps', () => {
172135
const props = createProps({ testID });
173136
expect(props['data-testid']).toEqual(testID);
174137
});
175-
176-
test('includes cursor style for pressable roles', () => {
177-
expect(createDOMProps('span', { accessibilityRole: 'link' }).className).toMatchSnapshot();
178-
expect(createDOMProps('span', { accessibilityRole: 'button' }).className).toMatchSnapshot();
179-
});
180-
181-
test('includes base reset style for browser-styled elements', () => {
182-
expect(createDOMProps('a').className).toMatchSnapshot();
183-
expect(createDOMProps('button').className).toMatchSnapshot();
184-
expect(createDOMProps('li').className).toMatchSnapshot();
185-
expect(createDOMProps('ul').className).toMatchSnapshot();
186-
});
187138
});

packages/react-native-web/src/modules/createDOMProps/index.js

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -123,45 +123,15 @@ const createDOMProps = (elementType, props) => {
123123
pointerEvents,
124124
style: providedStyle,
125125
testID,
126-
// Deprecated
127-
accessible,
128-
accessibilityState,
129-
accessibilityValue,
126+
isRTL,
130127
// Rest
131128
...domProps
132129
} = props;
133130

134-
const disabled =
135-
(accessibilityState != null && accessibilityState.disabled === true) || accessibilityDisabled;
131+
const disabled = accessibilityDisabled;
136132

137133
const role = AccessibilityUtil.propsToAriaRole(props);
138134

139-
// DEPRECATED
140-
if (accessibilityState != null) {
141-
for (const prop in accessibilityState) {
142-
const value = accessibilityState[prop];
143-
if (value != null) {
144-
if (prop === 'disabled' || prop === 'hidden') {
145-
if (value === true) {
146-
domProps[`aria-${prop}`] = value;
147-
// also set prop directly to pick up host elementType behaviour
148-
domProps[prop] = value;
149-
}
150-
} else {
151-
domProps[`aria-${prop}`] = value;
152-
}
153-
}
154-
}
155-
}
156-
if (accessibilityValue != null) {
157-
for (const prop in accessibilityValue) {
158-
const value = accessibilityValue[prop];
159-
if (value != null) {
160-
domProps[`aria-value${prop}`] = value;
161-
}
162-
}
163-
}
164-
165135
// ACCESSIBILITY
166136
if (accessibilityActiveDescendant != null) {
167137
domProps['aria-activedescendant'] = accessibilityActiveDescendant;
@@ -336,36 +306,35 @@ const createDOMProps = (elementType, props) => {
336306

337307
// FOCUS
338308
// "focusable" indicates that an element may be a keyboard tab-stop.
339-
const _focusable = focusable != null ? focusable : accessible;
340-
if (_focusable === false) {
309+
if (focusable === false) {
341310
domProps.tabIndex = '-1';
342311
}
343312
if (
344-
// These native elements are focusable by default
313+
// These native elements are keyboard focusable by default
345314
elementType === 'a' ||
346315
elementType === 'button' ||
347316
elementType === 'input' ||
348317
elementType === 'select' ||
349318
elementType === 'textarea'
350319
) {
351-
if (_focusable === false || accessibilityDisabled === true) {
320+
if (focusable === false || accessibilityDisabled === true) {
352321
domProps.tabIndex = '-1';
353322
}
354323
} else if (
355-
// These roles are made focusable by default
324+
// These roles are made keyboard focusable by default
356325
role === 'button' ||
357326
role === 'checkbox' ||
358327
role === 'link' ||
359328
role === 'radio' ||
360329
role === 'textbox' ||
361330
role === 'switch'
362331
) {
363-
if (_focusable !== false) {
332+
if (focusable !== false) {
364333
domProps.tabIndex = '0';
365334
}
366335
} else {
367336
// Everything else must explicitly set the prop
368-
if (_focusable === true) {
337+
if (focusable === true) {
369338
domProps.tabIndex = '0';
370339
}
371340
}

packages/react-native-web/src/modules/forwardedProps/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ export const accessibilityProps = {
6464
accessibilityValueNow: true,
6565
accessibilityValueText: true,
6666
dir: true,
67-
focusable: true,
68-
// Deprecated
69-
accessible: true,
70-
accessibilityState: true,
71-
accessibilityValue: true
67+
focusable: true
7268
};
7369

7470
export const clickProps = {

0 commit comments

Comments
 (0)