Skip to content

Commit f6eb20e

Browse files
author
Megan Gross
committed
[144mdgross] - Set attribute on the SnackBar div so screen readers are able to read the actionTextAria message.
1 parent 227cf60 commit f6eb20e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

demo/Snackbar.html

+14
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,20 @@ <h4 style="margin-bottom: 3px;">configuration</h4>
237237
</td>
238238
<td>Text to display as the action button.</td>
239239
</tr>
240+
<tr>
241+
<td>actionTextAria</td>
242+
<td>
243+
<i>Dismiss, Description for Screen Readers</i>
244+
</td>
245+
<td>Text for screen readers.</td>
246+
</tr>
247+
<tr>
248+
<td>alertScreenReader</td>
249+
<td>
250+
<i>false</i>
251+
</td>
252+
<td>Determines if screen readers will annouce the snackbar message.</td>
253+
</tr>
240254
<tr>
241255
<td>actionTextColor</td>
242256
<td>

src/js/snackbar.js

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
showAction: true,
3131
actionText: 'Dismiss',
3232
actionTextAria: 'Dismiss, Description for Screen Readers',
33+
alertScreenReader: false,
3334
actionTextColor: '#4CAF50',
3435
showSecondButton: false,
3536
secondButtonText: '',
@@ -114,6 +115,10 @@
114115
);
115116
}
116117

118+
if (options.alertScreenReader) {
119+
Snackbar.snackbar.setAttribute('role', 'alert');
120+
}
121+
117122
Snackbar.snackbar.addEventListener(
118123
'transitionend',
119124
function(event, elapsed) {

0 commit comments

Comments
 (0)