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

Fix accessible prop for Image #2327

Merged
merged 13 commits into from
Jan 13, 2025
5 changes: 5 additions & 0 deletions packages/react-native/Libraries/Image/RCTImageView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,11 @@ - (RCTPlatformView *)reactAccessibilityElement
return _imageView;
}

- (NSCell *)reactAccessibilityElementCell
{
return _imageView.cell;
}

- (NSColor *)tintColor
{
return _imageView.tintColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ - (RCTPlatformView *)view // [macOS]
return [[RCTImageView alloc] initWithBridge:self.bridge];
}

RCT_REMAP_VIEW_PROPERTY(accessible, reactAccessibilityElementCell.accessibilityElement, BOOL)
RCT_EXPORT_VIEW_PROPERTY(blurRadius, CGFloat)
RCT_EXPORT_VIEW_PROPERTY(capInsets, UIEdgeInsets)
RCT_REMAP_VIEW_PROPERTY(defaultSource, defaultImage, UIImage)
Expand Down
8 changes: 8 additions & 0 deletions packages/rn-tester/js/examples/Image/ImageExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,14 @@ exports.examples = [
return <Image accessible source={fullImage} style={styles.base} />;
},
},
{
title: 'Accessibility Remove From Tree',
description:
('If the `accessible` (boolean) prop is set to False, the image will be removed from the accessbility tree.': string),
render: function (): React.Node {
return <Image accessible={false} source={fullImage} style={styles.base} />;
},
},
{
title: 'Accessibility Label',
description:
Expand Down
Loading