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

feat: support aria-hidden prop #1474

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/helpers/__tests__/format-default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const node: ReactTestRendererJSON = {
describe('mapPropsForQueryError', () => {
test('preserves props that are helpful for debugging', () => {
const props = {
'aria-hidden': true,
accessibilityElementsHidden: true,
accessibilityViewIsModal: true,
importantForAccessibility: 'yes',
Expand All @@ -25,7 +26,6 @@ describe('mapPropsForQueryError', () => {
};

const result = defaultMapProps(props, node);

expect(result).toStrictEqual(props);
});

Expand Down
1 change: 1 addition & 0 deletions src/helpers/accessiblity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function isSubtreeInaccessible(element: ReactTestInstance): boolean {
return false;
}

// See: https://reactnative.dev/docs/accessibility#aria-hidden
if (element.props['aria-hidden']) {
return true;
}
Expand Down
1 change: 1 addition & 0 deletions src/helpers/format-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const propsToDisplay = [
'accessibilityLabel',
'accessibilityLabelledBy',
'accessibilityHint',
'aria-hidden',
'placeholder',
'value',
'defaultValue',
Expand Down
2 changes: 2 additions & 0 deletions src/queries/__tests__/makeQueries.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('printing element tree', () => {
test('prints helpful props but not others', async () => {
const { getByText } = render(
<View
aria-hidden
accessibilityElementsHidden
accessibilityViewIsModal
importantForAccessibility="yes"
Expand Down Expand Up @@ -48,6 +49,7 @@ describe('printing element tree', () => {
accessibilityLabelledBy="LABELLED_BY"
accessibilityRole="summary"
accessibilityViewIsModal={true}
aria-hidden={true}
importantForAccessibility="yes"
nativeID="NATIVE_ID"
testID="TEST_ID"
Expand Down
1 change: 1 addition & 0 deletions website/docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ This covers only part of [ARIA notion of Accessiblity Tree](https://www.w3.org/T
For the scope of this function, element is inaccessible when it, or any of its ancestors, meets any of the following conditions:

- it has `display: none` style
- it has [`aria-hidden`](https://reactnative.dev/docs/accessibility#aria-hidden) prop set to `true`
- it has [`accessibilityElementsHidden`](https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios) prop set to `true`
- it has [`importantForAccessibility`](https://reactnative.dev/docs/accessibility#importantforaccessibility-android) prop set to `no-hide-descendants`
- it has sibling host element with [`accessibilityViewIsModal`](https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios) prop set to `true`
Expand Down