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

Added support for importantForAccessibility for some components #31296

Closed
7 changes: 0 additions & 7 deletions Libraries/Image/ImageBackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,9 @@ class ImageBackground extends React.Component<$FlowFixMeProps> {
render(): React.Node {
const {children, style, imageStyle, imageRef, ...props} = this.props;

// If `no` is specified for `importantForAccessibility`, it will be changed to `no-hide-descendants` because the text inside should not be focused.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't importantForAccessibility no longer work at all on ImageBackgrounds now?

I think we should still have this property, it just should work like normal where no = no and no_hide_descendants = no_hide_descendants.

If this is magically being inherited from somewhere else and it does work still, feel free to ignore my comment :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seem to have misunderstood.
ImageBackgrounds' importantForAccessibility is given to the Image inside, not the Wrapper itself, and it doesn't seem to work because of that.
I will fix this. Thanks!

const _importantForAccessibility =
this.props.importantForAccessibility === 'no'
? 'no-hide-descendants'
: this.props.importantForAccessibility;

return (
<View
accessibilityIgnoresInvertColors={true}
importantForAccessibility={_importantForAccessibility}
style={style}
ref={this._captureRef}>
<Image
Expand Down
13 changes: 1 addition & 12 deletions Libraries/Image/__tests__/ImageBackground-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,7 @@ describe('<ImageBackground />', () => {
expect(instance).toMatchSnapshot();
});

it('should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no-hide-descendants}', () => {
const instance = render.create(
<ImageBackground
importantForAccessibility={'no-hide-descendants'}
style={{width: 150, height: 50}}
source={{uri: 'foo-bar.jpg'}}
/>,
);
expect(instance).toMatchSnapshot();
});

it('should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no}', () => {
it('should be set importantForAccessibility={no} when importantForAccessibility={no}', () => {
const instance = render.create(
<ImageBackground
importantForAccessibility={'no'}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<ImageBackground /> should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no} 1`] = `
exports[`<ImageBackground /> should be set importantForAccessibility={no} when importantForAccessibility={no} 1`] = `
<View
accessibilityIgnoresInvertColors={true}
importantForAccessibility="no-hide-descendants"
style={
Object {
"height": 50,
Expand Down Expand Up @@ -38,44 +37,6 @@ exports[`<ImageBackground /> should be set importantForAccessibility={no-hide-de
</View>
`;

exports[`<ImageBackground /> should be set importantForAccessibility={no-hide-descendants} when importantForAccessibility={no-hide-descendants} 1`] = `
<View
accessibilityIgnoresInvertColors={true}
importantForAccessibility="no-hide-descendants"
style={
Object {
"height": 50,
"width": 150,
}
}
>
<Image
importantForAccessibility="no-hide-descendants"
source={
Object {
"uri": "foo-bar.jpg",
}
}
style={
Array [
Object {
"bottom": 0,
"left": 0,
"position": "absolute",
"right": 0,
"top": 0,
},
Object {
"height": 50,
"width": 150,
},
undefined,
]
}
/>
</View>
`;

exports[`<ImageBackground /> should render as <ImageBackground> when mocked 1`] = `
<View
accessibilityIgnoresInvertColors={true}
Expand Down