Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(alert): not announced correctly in screen reader (VIV-1970) #2235

Merged
merged 7 commits into from
Mar 27, 2025

Conversation

TaylorJ76
Copy link
Contributor

@TaylorJ76 TaylorJ76 commented Mar 18, 2025

When the dismiss button is present, it receives focus when the alert is opened.
This is beneficial to keyboard only and screen reader users, because they don't have to tab around to find the button.

@TaylorJ76 TaylorJ76 changed the title fix(alert): not announced correctly in screen reader fix(alert): not announced correctly in screen reader (VIV-1970) Mar 18, 2025
Copy link
Contributor

⚠️ The generated metadata has changed. I have updated the metadata file for you. Please review the changes:

View Diff

Copy link

codecov bot commented Mar 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (d61b119) to head (9a778e0).
Report is 1371 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##              main     #2235      +/-   ##
============================================
  Coverage   100.00%   100.00%              
============================================
  Files          123       375     +252     
  Lines         1562     16688   +15126     
  Branches       108      2928    +2820     
============================================
+ Hits          1562     16688   +15126     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

${renderIcon(context)}
<div class="alert-text">
${when(
(x) => x.headline,
html`<header class="headline">${(x) => x.headline}</header>`
html`<div class="headline">${(x) => x.headline}</div>`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't it an issue for readability of the alert?

Comment on lines 72 to 79

// export const AlertTemplate = (context: VividElementDefinitionContext) => {
// return html<Alert>`
// <div role="alert">
// ${(x) => x.open ? x.text : null}
// </div>
// `;
// };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// export const AlertTemplate = (context: VividElementDefinitionContext) => {
// return html<Alert>`
// <div role="alert">
// ${(x) => x.open ? x.text : null}
// </div>
// `;
// };

) as HTMLElement;
if (this.removable && alertText) {
alertText.setAttribute('tabindex', '0');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the tabindex is not needed anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because focus is set to the close button.
Plus, setting focus to the alert-text element didn't make the screen-reader announce the text.

@@ -44,17 +45,19 @@ export const AlertTemplate = (context: VividElementDefinitionContext) => {

return html<Alert>`
<${elevationTag} class="elevation" dp='8' exportparts="vvd-theme-alternate">
<div
class="${getControlClasses}"
role="${(x) => (x.removable ? 'alertdialog' : 'alert')}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for alertdialog?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. It's not an alertdialog (like a confirmation dialog), it is a closable alert.
I checked how other design system's tackled it and this seemed to be the most common.
Also, it works as expected.

@TaylorJ76 TaylorJ76 merged commit e2af9d8 into main Mar 27, 2025
17 checks passed
@TaylorJ76 TaylorJ76 deleted the VIV-1970-alert-a11y-close-btn branch March 27, 2025 10:16
@github-actions github-actions bot mentioned this pull request Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants