Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const ActivityIndicator: component(
onLayout,
size = 'small',
style,
'aria-hidden': ariaHidden,
...restProps
}: {
ref?: React.RefSetter<ActivityIndicatorInstance>,
Expand Down Expand Up @@ -155,6 +156,7 @@ const ActivityIndicator: component(

return (
<View
aria-hidden={ariaHidden}
onLayout={onLayout}
style={StyleSheet.compose(styles.container, style)}>
{Platform.OS === 'android' ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,18 @@ describe('ActivityIndicator', () => {
),
).toEqual(<rn-androidProgressBar width="20" height="20" />);
});

it('maps aria-hidden to importantForAccessibility around its indicator', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<ActivityIndicator aria-hidden={true} />);
});
expect(
root.getRenderedOutput({props: ['importantForAccessibility']}).toJSX(),
).toEqual(
<rn-view importantForAccessibility="no-hide-descendants">
<rn-androidProgressBar />
</rn-view>,
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -1858,10 +1858,19 @@ class ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {

const baseStyle = horizontal ? styles.baseHorizontal : styles.baseVertical;

const {experimental_endDraggingSensitivityMultiplier, ...otherProps} =
this.props;
const {
experimental_endDraggingSensitivityMultiplier,
'aria-hidden': ariaHidden,
...otherProps
} = this.props;
const props = {
...otherProps,
accessibilityElementsHidden:
ariaHidden ?? this.props.accessibilityElementsHidden,
importantForAccessibility:
ariaHidden === true
? ('no-hide-descendants' as const)
: this.props.importantForAccessibility,
alwaysBounceHorizontal,
alwaysBounceVertical,
style: StyleSheet.compose(baseStyle, this.props.style),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,60 @@ describe('<ScrollView>', () => {
});
});

describe('aria-hidden', () => {
it('is mapped to importantForAccessibility', () => {
const root = Fantom.createRoot();

Fantom.runTask(() => {
root.render(<ScrollView aria-hidden={true} />);
});

expect(
root.getRenderedOutput({props: ['importantForAccessibility']}).toJSX(),
).toEqual(
<rn-scrollView importantForAccessibility="no-hide-descendants">
<rn-view />
</rn-scrollView>,
);
});

it('resets importantForAccessibility when set to undefined', () => {
const root = Fantom.createRoot();

Fantom.runTask(() => {
root.render(<ScrollView aria-hidden={true} />);
});

Fantom.runTask(() => {
root.render(<ScrollView />);
});

expect(
root.getRenderedOutput({props: ['importantForAccessibility']}).toJSX(),
).toEqual(
<rn-scrollView>
<rn-view />
</rn-scrollView>,
);
});

it('leaves an explicit importantForAccessibility in place when absent', () => {
const root = Fantom.createRoot();

Fantom.runTask(() => {
root.render(<ScrollView importantForAccessibility="no" />);
});

expect(
root.getRenderedOutput({props: ['importantForAccessibility']}).toJSX(),
).toEqual(
<rn-scrollView importantForAccessibility="no">
<rn-view />
</rn-scrollView>,
);
});
});

describe('ref', () => {
it('receives an instance or null', () => {
const root = Fantom.createRoot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import * as React from 'react';
import {createRef, useEffect, useRef, useState} from 'react';
import {
AccessibilityInfo,
ActivityIndicator,
Alert,
Button,
Image,
Expand Down Expand Up @@ -2265,6 +2266,16 @@ function AriaHiddenExample(): React.Node {
source={require('../../assets/like.png')}
style={styles.button}
/>

<ScrollView aria-hidden={ariaHidden} style={{maxHeight: 60}}>
<Text>
{ariaHidden
? 'ScrollView content that should be hidden'
: 'ScrollView content that should be accessible'}
</Text>
</ScrollView>

<ActivityIndicator aria-hidden={ariaHidden} />
</View>
);
}
Expand Down
Loading