Skip to content

Commit 322bc2c

Browse files
authored
fix(react): hide svg icon images in a11y tree in Rating component (#2469)
* fix(react): hide svg icon images in a11y tree in Rating component
1 parent ed41e28 commit 322bc2c

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

.changeset/silver-moles-wait.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@aws-amplify/ui-react": patch
3+
---
4+
5+
fix(react): hide svg icon images in a11y tree in Rating component so redundant text is not announced

docs/src/pages/[platform]/components/rating/examples/RatingEmptyExample.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { Rating, Icon } from '@aws-amplify/ui-react';
22

33
const IconStarBorder = () => {
44
return (
5-
<Icon
6-
ariaLabel="No rating"
7-
pathData="M22 9.24L14.81 8.62L12 2L9.19 8.63L2 9.24L7.46 13.97L5.82 21L12 17.27L18.18 21L16.55 13.97L22 9.24ZM12 15.4L8.24 17.67L9.24 13.39L5.92 10.51L10.3 10.13L12 6.1L13.71 10.14L18.09 10.52L14.77 13.4L15.77 17.68L12 15.4Z"
8-
/>
5+
<Icon pathData="M22 9.24L14.81 8.62L12 2L9.19 8.63L2 9.24L7.46 13.97L5.82 21L12 17.27L18.18 21L16.55 13.97L22 9.24ZM12 15.4L8.24 17.67L9.24 13.39L5.92 10.51L10.3 10.13L12 6.1L13.71 10.14L18.09 10.52L14.77 13.4L15.77 17.68L12 15.4Z" />
96
);
107
};
118

docs/src/pages/[platform]/components/rating/examples/RatingIconExample.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import { Rating, Icon } from '@aws-amplify/ui-react';
22

33
const IconAdd = () => {
4-
return (
5-
<Icon
6-
ariaLabel="No rating"
7-
pathData="M19 13H13V19H11V13H5V11H11V5H13V11H19V13Z"
8-
/>
9-
);
4+
return <Icon pathData="M19 13H13V19H11V13H5V11H11V5H13V11H19V13Z" />;
105
};
116

127
export const RatingIconExample = () => {

packages/react/src/primitives/Rating/RatingIcon.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ export const RatingIcon: React.FC<RatingIconProps> = ({
1717
className,
1818
}) => {
1919
return (
20-
<View as="span" className="amplify-rating-icon-container">
20+
<View
21+
as="span"
22+
className="amplify-rating-icon-container"
23+
aria-hidden="true"
24+
>
2125
<View as="span" className={classNames(className)} color={fill}>
2226
{icon}
2327
</View>

packages/react/src/primitives/Rating/RatingMixedIcon.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ export const RatingMixedIcon: React.FC<RatingMixedIconProps> = ({
2121
}) => {
2222
const widthPercentage = `${(value % 1) * 100}%`;
2323
return (
24-
<View as="span" className="amplify-rating-icon-container">
24+
<View
25+
as="span"
26+
className="amplify-rating-icon-container"
27+
aria-hidden="true"
28+
>
2529
<View as="span" className="amplify-rating-label">
2630
<View
2731
as="span"

0 commit comments

Comments
 (0)