File tree Expand file tree Collapse file tree 5 files changed +59
-6
lines changed
angular/projects/ui-angular/src/lib/primitives/error
vue/src/components/primitives Expand file tree Collapse file tree 5 files changed +59
-6
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @aws-amplify/ui-angular ' : patch
3+ ' @aws-amplify/ui-vue ' : patch
4+ ---
5+
6+ Adds an accessible label for the Alert dismiss button, which is configurable via translation.
Original file line number Diff line number Diff line change 2020 </ div >
2121 < button
2222 amplify-button
23- class ="amplify-field-group__control "
23+ class ="amplify-field-group__control amplify-alert__dismiss "
24+ [attr.aria-label] ="dismissAriaLabel "
2425 variation ="link "
2526 [fullWidth] ="false "
2627 (click) ="close() "
Original file line number Diff line number Diff line change 11import { Component } from '@angular/core' ;
2+ import { translate } from '@aws-amplify/ui' ;
23
34@Component ( {
45 selector : 'amplify-error' ,
56 templateUrl : './error.component.html' ,
67} )
78export class ErrorComponent {
89 public isVisible = true ;
10+ public dismissAriaLabel = translate ( 'Dismiss alert' ) ;
911
1012 public close ( ) {
1113 this . isVisible = false ;
Original file line number Diff line number Diff line change 1+ import BaseAlert from '../base-alert.vue' ;
2+ import { components } from '../../../../global-spec' ;
3+ import { render } from '@testing-library/vue' ;
4+
5+ import { I18n } from 'aws-amplify' ;
6+
7+ describe ( 'Base Alert' , ( ) => {
8+ it ( 'Base Alert Exists' , ( ) => {
9+ const wrapper = render ( BaseAlert , {
10+ global : {
11+ components,
12+ } ,
13+ } ) ;
14+
15+ expect ( wrapper ) . toBeTruthy ( ) ;
16+ } ) ;
17+
18+ it ( 'shows correct default accessible label' , ( ) => {
19+ const { queryByRole } = render ( BaseAlert , {
20+ global : {
21+ components,
22+ } ,
23+ } ) ;
24+
25+ const defaultButton = queryByRole ( 'button' ) ;
26+ expect ( defaultButton ?. getAttribute ( 'aria-label' ) ) . toBe ( 'Dismiss alert' ) ;
27+ } ) ;
28+ it ( 'shows correct default translated label' , ( ) => {
29+ const translatedAriaLabel = 'Translated dismiss alert' ;
30+ I18n . putVocabulariesForLanguage ( 'en' , {
31+ 'Dismiss alert' : translatedAriaLabel ,
32+ } ) ;
33+ const { queryByRole } = render ( BaseAlert , {
34+ global : {
35+ components,
36+ } ,
37+ } ) ;
38+
39+ const defaultButton = queryByRole ( 'button' ) ;
40+ expect ( defaultButton ?. getAttribute ( 'aria-label' ) ) . toBe ( translatedAriaLabel ) ;
41+ } ) ;
42+ } ) ;
Original file line number Diff line number Diff line change 11<script setup>
22import { ref } from ' vue' ;
3+ import { translate } from ' @aws-amplify/ui' ;
4+
35const show = ref (true );
46
7+ const dismissAriaLabel = translate (' Dismiss alert' );
8+
59function close () {
610 show .value = false ;
711}
@@ -10,10 +14,7 @@ function close() {
1014<template >
1115 <div
1216 v-if =" show"
13- class ="
14- amplify-flex amplify-alert amplify-alert--error
15- amplify-authenticator__base
16- "
17+ class =" amplify-flex amplify-alert amplify-alert--error amplify-authenticator__base"
1718 data-variation =" error"
1819 role =" alert"
1920 >
@@ -31,7 +32,8 @@ function close() {
3132 <div ><slot ></slot ></div >
3233 </div >
3334 <amplify-button
34- class =" amplify-field-group__control"
35+ class =" amplify-field-group__control amplify-alert__dismiss"
36+ :aria-label =" dismissAriaLabel"
3537 :fullwidth =" false"
3638 :variation =" 'link'"
3739 type =" button"
You can’t perform that action at this time.
0 commit comments