Skip to content

Commit

Permalink
[fix] alt text on Image; role on label
Browse files Browse the repository at this point in the history
Close #2666
Fix #2665
  • Loading branch information
ayroblu authored and necolas committed May 22, 2024
1 parent 12db5a2 commit 2106944
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/react-native-web/src/exports/Image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ const Image: React.AbstractComponent<
React.ElementRef<typeof View>
> = React.forwardRef((props, ref) => {
const {
'aria-label': ariaLabel,
'aria-label': _ariaLabel,
accessibilityLabel,
blurRadius,
defaultSource,
draggable,
Expand All @@ -189,6 +190,7 @@ const Image: React.AbstractComponent<
style,
...rest
} = props;
const ariaLabel = _ariaLabel || accessibilityLabel;

if (process.env.NODE_ENV !== 'production') {
if (props.children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ const emptyObject = {};
const propsToAccessibilityComponent = (
props: Object = emptyObject
): void | string => {
const roleProp = props.role || props.accessibilityRole;
// special-case for "label" role which doesn't map to an ARIA role
if (props.accessibilityRole === 'label') {
if (roleProp === 'label') {
return 'label';
}

Expand Down

0 comments on commit 2106944

Please sign in to comment.