mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Revert: Automatically set acessible prop when role prop is set (except none/presenation) (#57743)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/57743 This diff reverts https://github.com/react/react-native/pull/57633 ## Changelog [GENERAL] [CHANGED] Revert: Automatically set acessible prop when role prop is set (except none/presenation) Reviewed By: javache Differential Revision: D113922297 fbshipit-source-id: 705fe67f5f712be5e7baccdd01603915f47893a1
This commit is contained in:
1 parent
544141efab
commit
adde1e5888
5 files changed
+3
-133
No files matched your search
@@ -83,16 +83,6 @@ component View(ref?: React.RefSetter<ViewInstance>, ...props: ViewProps) {
|
||||
resolvedProps.focusable = !tabIndex;
|
||||
}
|
||||
|
||||
// For web compatibility, a `role` implicitly makes the element accessible.
|
||||
if (
|
||||
resolvedProps.accessible == null &&
|
||||
resolvedProps.role != null &&
|
||||
resolvedProps.role !== 'none' &&
|
||||
resolvedProps.role !== 'presentation'
|
||||
) {
|
||||
resolvedProps.accessible = true;
|
||||
}
|
||||
|
||||
if (
|
||||
accessibilityState != null ||
|
||||
ariaBusy != null ||
|
||||
|
||||
@@ -643,59 +643,6 @@ describe('<View>', () => {
|
||||
).toEqual(null);
|
||||
});
|
||||
});
|
||||
describe('role', () => {
|
||||
it('implicitly makes the view accessible', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(<View role="button" />);
|
||||
});
|
||||
|
||||
expect(
|
||||
root.getRenderedOutput({props: ['accessible']}).toJSX(),
|
||||
).toEqual(<rn-view accessible="true" />);
|
||||
});
|
||||
|
||||
it('does not make the view accessible for the "none" role', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(<View role="none" collapsable={false} />);
|
||||
});
|
||||
|
||||
expect(
|
||||
root.getRenderedOutput({props: ['accessible']}).toJSX(),
|
||||
).toEqual(<rn-view />);
|
||||
});
|
||||
|
||||
it('does not make the view accessible for the "presentation" role', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(<View role="presentation" collapsable={false} />);
|
||||
});
|
||||
|
||||
expect(
|
||||
root.getRenderedOutput({props: ['accessible']}).toJSX(),
|
||||
).toEqual(<rn-view />);
|
||||
});
|
||||
|
||||
it('does not override an explicit "accessible" prop', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(
|
||||
<View role="button" accessible={false} collapsable={false} />,
|
||||
);
|
||||
});
|
||||
|
||||
// `accessible={false}` is not propagated to the mounting layer (it is
|
||||
// the default), so the implicit `role` behavior must not force it on.
|
||||
expect(
|
||||
root.getRenderedOutput({props: ['accessible']}).toJSX(),
|
||||
).toEqual(<rn-view />);
|
||||
});
|
||||
});
|
||||
describe('aria-label', () => {
|
||||
it('is mapped to accessibilityLabel', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
@@ -284,13 +284,6 @@ let BaseImage: AbstractImageAndroid = ({
|
||||
nativeProps.accessible = true;
|
||||
} else if (accessible != null) {
|
||||
nativeProps.accessible = accessible;
|
||||
} else if (
|
||||
// For web compatibility, a `role` implicitly makes the element accessible.
|
||||
nativeProps.role != null &&
|
||||
nativeProps.role !== 'none' &&
|
||||
nativeProps.role !== 'presentation'
|
||||
) {
|
||||
nativeProps.accessible = true;
|
||||
}
|
||||
|
||||
if (
|
||||
|
||||
@@ -168,23 +168,9 @@ let BaseImage: AbstractImageIOS = ({
|
||||
selected: ariaSelected ?? props.accessibilityState?.selected,
|
||||
};
|
||||
|
||||
let accessible;
|
||||
if (ariaHidden === true) {
|
||||
// In order for `aria-hidden` to work on iOS we must set `accessible` to
|
||||
// false (`accessibilityElementsHidden` is not enough).
|
||||
accessible = false;
|
||||
} else if (props.alt !== undefined) {
|
||||
accessible = true;
|
||||
} else if (props.accessible != null) {
|
||||
accessible = props.accessible;
|
||||
} else if (
|
||||
// For web compatibility, a `role` implicitly makes the element accessible.
|
||||
props.role != null &&
|
||||
props.role !== 'none' &&
|
||||
props.role !== 'presentation'
|
||||
) {
|
||||
accessible = true;
|
||||
}
|
||||
// In order for `aria-hidden` to work on iOS we must set `accessible` to false (`accessibilityElementsHidden` is not enough).
|
||||
const accessible =
|
||||
ariaHidden !== true && (props.alt !== undefined ? true : props.accessible);
|
||||
const accessibilityLabel = props['aria-label'] ?? props.accessibilityLabel;
|
||||
|
||||
const actualRef = useWrapRefWithImageAttachedCallbacks(forwardedRef);
|
||||
|
||||
@@ -648,52 +648,6 @@ describe('<Image>', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('role', () => {
|
||||
it('implicitly marks the image accessible', () => {
|
||||
const root = Fantom.createRoot();
|
||||
Fantom.runTask(() => {
|
||||
root.render(<Image role="button" source={LOGO_SOURCE} />);
|
||||
});
|
||||
expect(root.getRenderedOutput({props: ['accessible']}).toJSX()).toEqual(
|
||||
<rn-image accessible="true" />,
|
||||
);
|
||||
});
|
||||
|
||||
it('does not mark the image accessible for the "none" role', () => {
|
||||
const root = Fantom.createRoot();
|
||||
Fantom.runTask(() => {
|
||||
root.render(<Image role="none" source={LOGO_SOURCE} />);
|
||||
});
|
||||
expect(root.getRenderedOutput({props: ['accessible']}).toJSX()).toEqual(
|
||||
<rn-image />,
|
||||
);
|
||||
});
|
||||
|
||||
it('does not mark the image accessible for the "presentation" role', () => {
|
||||
const root = Fantom.createRoot();
|
||||
Fantom.runTask(() => {
|
||||
root.render(<Image role="presentation" source={LOGO_SOURCE} />);
|
||||
});
|
||||
expect(root.getRenderedOutput({props: ['accessible']}).toJSX()).toEqual(
|
||||
<rn-image />,
|
||||
);
|
||||
});
|
||||
|
||||
it('does not override an explicit "accessible" prop', () => {
|
||||
const root = Fantom.createRoot();
|
||||
Fantom.runTask(() => {
|
||||
root.render(
|
||||
<Image role="button" accessible={false} source={LOGO_SOURCE} />,
|
||||
);
|
||||
});
|
||||
// `accessible={false}` is not propagated to the mounting layer (it is
|
||||
// the default), so the implicit `role` behavior must not force it on.
|
||||
expect(root.getRenderedOutput({props: ['accessible']}).toJSX()).toEqual(
|
||||
<rn-image />,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
component TestComponent(testID?: ?string, ...props: AccessibilityProps) {
|
||||
return <Image {...props} testID={testID} source={LOGO_SOURCE} />;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user