diff --git a/src/helpers/__tests__/format-default.tsx b/src/helpers/__tests__/format-default.tsx index 6cd49c5fc..21d8e979b 100644 --- a/src/helpers/__tests__/format-default.tsx +++ b/src/helpers/__tests__/format-default.tsx @@ -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', @@ -25,7 +26,6 @@ describe('mapPropsForQueryError', () => { }; const result = defaultMapProps(props, node); - expect(result).toStrictEqual(props); }); diff --git a/src/helpers/accessiblity.ts b/src/helpers/accessiblity.ts index 273d84d3b..9e50a8832 100644 --- a/src/helpers/accessiblity.ts +++ b/src/helpers/accessiblity.ts @@ -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; } diff --git a/src/helpers/format-default.ts b/src/helpers/format-default.ts index 0f2329329..79880f952 100644 --- a/src/helpers/format-default.ts +++ b/src/helpers/format-default.ts @@ -11,6 +11,7 @@ const propsToDisplay = [ 'accessibilityLabel', 'accessibilityLabelledBy', 'accessibilityHint', + 'aria-hidden', 'placeholder', 'value', 'defaultValue', diff --git a/src/queries/__tests__/makeQueries.test.tsx b/src/queries/__tests__/makeQueries.test.tsx index f7658a4c0..8175ebbe5 100644 --- a/src/queries/__tests__/makeQueries.test.tsx +++ b/src/queries/__tests__/makeQueries.test.tsx @@ -18,6 +18,7 @@ describe('printing element tree', () => { test('prints helpful props but not others', async () => { const { getByText } = render( { accessibilityLabelledBy="LABELLED_BY" accessibilityRole="summary" accessibilityViewIsModal={true} + aria-hidden={true} importantForAccessibility="yes" nativeID="NATIVE_ID" testID="TEST_ID" diff --git a/website/docs/API.md b/website/docs/API.md index c1911ae54..5fdefce56 100644 --- a/website/docs/API.md +++ b/website/docs/API.md @@ -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`