diff --git a/packages/react-native/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-itest.js b/packages/react-native/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-itest.js index 7b7897545dc2..edfcc89cbd92 100644 --- a/packages/react-native/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-itest.js +++ b/packages/react-native/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-itest.js @@ -66,4 +66,38 @@ describe('ActivityIndicator', () => { root.getRenderedOutput({props: ['accessibilityLabel']}).toJSX(), ).toEqual(); }); + + it('maps aria-hidden to importantForAccessibility', () => { + const root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render(); + }); + + expect( + root.getRenderedOutput({props: ['importantForAccessibility']}).toJSX(), + ).toEqual( + , + ); + }); + + it('resets importantForAccessibility when aria-hidden is removed', () => { + const root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render(); + }); + + expect( + root.getRenderedOutput({props: ['importantForAccessibility']}).toJSX(), + ).toEqual( + , + ); + + Fantom.runTask(() => { + root.render(); + }); + + expect( + root.getRenderedOutput({props: ['importantForAccessibility']}).toJSX(), + ).toEqual(); + }); }); diff --git a/packages/react-native/Libraries/Components/ScrollView/__tests__/ScrollView-itest.js b/packages/react-native/Libraries/Components/ScrollView/__tests__/ScrollView-itest.js index d98e792fa94a..e5eaa068debf 100644 --- a/packages/react-native/Libraries/Components/ScrollView/__tests__/ScrollView-itest.js +++ b/packages/react-native/Libraries/Components/ScrollView/__tests__/ScrollView-itest.js @@ -101,6 +101,84 @@ describe('', () => { , ); }); + + it('maps aria-hidden to importantForAccessibility', () => { + const root = Fantom.createRoot(); + + Fantom.runTask(() => { + root.render(); + }); + + expect( + root.getRenderedOutput({props: ['importantForAccessibility']}).toJSX(), + ).toEqual( + + + , + ); + }); + + it('resets importantForAccessibility when aria-hidden is removed', () => { + const root = Fantom.createRoot(); + + Fantom.runTask(() => { + root.render(); + }); + + expect( + root.getRenderedOutput({props: ['importantForAccessibility']}).toJSX(), + ).toEqual( + + + , + ); + + Fantom.runTask(() => { + root.render(); + }); + + expect( + root.getRenderedOutput({props: ['importantForAccessibility']}).toJSX(), + ).toEqual( + + + , + ); + }); + + it('keeps an explicit importantForAccessibility when aria-hidden is absent', () => { + const root = Fantom.createRoot(); + + Fantom.runTask(() => { + root.render(); + }); + + expect( + root.getRenderedOutput({props: ['importantForAccessibility']}).toJSX(), + ).toEqual( + + + , + ); + }); + + it('keeps an explicit importantForAccessibility when aria-hidden is false', () => { + const root = Fantom.createRoot(); + + Fantom.runTask(() => { + root.render( + , + ); + }); + + expect( + root.getRenderedOutput({props: ['importantForAccessibility']}).toJSX(), + ).toEqual( + + + , + ); + }); }); describe('hitSlop', () => { diff --git a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js index 828b1b6260d2..4c09d429f091 100644 --- a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js +++ b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js @@ -22,6 +22,7 @@ import * as React from 'react'; import {createRef, useEffect, useRef, useState} from 'react'; import { AccessibilityInfo, + ActivityIndicator, Alert, Button, Image, @@ -2269,6 +2270,16 @@ function AriaHiddenExample(): React.Node { source={require('../../assets/like.png')} style={styles.button} /> + + + + {ariaHidden + ? 'ScrollView content that should be hidden' + : 'ScrollView content that should be accessible'} + + + + ); }