Skip to content

Commit

Permalink
feat: support aria-hidden prop (#1474)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjastrzebski authored Aug 31, 2023
1 parent f0fee35 commit 238c860
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 1 deletion.
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

0 comments on commit 238c860

Please sign in to comment.