Skip to content

Commit 8def8dc

Browse files
authored
fix(ui-angular + ui-vue): Hide decorative alert icons from screen readers (#2419)
1 parent bbf09dd commit 8def8dc

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

.changeset/weak-pillows-dream.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@aws-amplify/ui-angular': patch
3+
'@aws-amplify/ui-vue': patch
4+
---
5+
6+
Hide decorative alert icons from screen readers.

packages/angular/projects/ui-angular/src/lib/primitives/error/error.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<svg
1010
xmlns="http://www.w3.org/2000/svg"
1111
class="amplify-icon"
12+
[attr.aria-hidden]="true"
1213
viewBox="0 0 24 24"
1314
fill="currentColor"
1415
>
@@ -29,6 +30,7 @@
2930
<svg
3031
xmlns="http://www.w3.org/2000/svg"
3132
class="amplify-icon"
33+
[attr.aria-hidden]="true"
3234
viewBox="0 0 24 24"
3335
fill="currentColor"
3436
>

packages/vue/src/components/primitives/__tests__/base-alert.spec.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import BaseAlert from '../base-alert.vue';
22
import { components } from '../../../../global-spec';
33
import { render } from '@testing-library/vue';
4-
54
import { I18n } from 'aws-amplify';
65

76
describe('Base Alert', () => {
@@ -25,6 +24,7 @@ describe('Base Alert', () => {
2524
const defaultButton = queryByRole('button');
2625
expect(defaultButton?.getAttribute('aria-label')).toBe('Dismiss alert');
2726
});
27+
2828
it('shows correct default translated label', () => {
2929
const translatedAriaLabel = 'Translated dismiss alert';
3030
I18n.putVocabulariesForLanguage('en', {
@@ -39,4 +39,15 @@ describe('Base Alert', () => {
3939
const defaultButton = queryByRole('button');
4040
expect(defaultButton?.getAttribute('aria-label')).toBe(translatedAriaLabel);
4141
});
42+
43+
it('should set aria-hidden to be true on dismiss button decorative icon', () => {
44+
const { queryByRole } = render(BaseAlert, {
45+
global: {
46+
components,
47+
},
48+
});
49+
const defaultButton = queryByRole('button');
50+
const icon = defaultButton?.children[0];
51+
expect(icon?.getAttribute('aria-hidden')).toBe('true');
52+
});
4253
});

packages/vue/src/components/primitives/base-alert.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function close() {
2222
<svg
2323
xmlns="http://www.w3.org/2000/svg"
2424
class="amplify-icon"
25+
aria-hidden="true"
2526
viewBox="0 0 24 24"
2627
fill="currentColor"
2728
>
@@ -42,6 +43,7 @@ function close() {
4243
<svg
4344
xmlns="http://www.w3.org/2000/svg"
4445
class="amplify-icon"
46+
aria-hidden="true"
4547
viewBox="0 0 24 24"
4648
fill="currentColor"
4749
>

0 commit comments

Comments
 (0)