Skip to content

feat: accessible toast and drop toastify#2324

Open
skjnldsv wants to merge 1 commit intomainfrom
fix/a11y
Open

feat: accessible toast and drop toastify#2324
skjnldsv wants to merge 1 commit intomainfrom
fix/a11y

Conversation

@skjnldsv
Copy link
Contributor

@skjnldsv skjnldsv commented Mar 17, 2026

Fix #2254

⚠️ Initially just a fix, afetr @susnux's comment, I decided it was a good thing to rewrite the implementation

Summary

Drop toastify-js

Removes toastify-js (last third-party UI dep for toasts) and replaces it with a self-contained ToastNotification.vue. The public API is unchanged.

  • Styling moved into the component using BEM, old SVG assets removed
  • Close and undo buttons now use NcButton, spinner uses NcLoadingIcon
  • Toasts slide in with a short fade+translate animation
  • Height aligned to --clickable-area-large, positioned below the header

Accessibility

  • Persistent aria-live regions (polite + assertive) are created once and reused, injecting a live region that already carries aria-live is unreliable in NVDA/JAWS, so they are pre-created before any toast is shown
  • Announcements are prefixed with the toast type using a translatable {message} placeholder ("Error: {message}") so the colour cue is also conveyed to screen readers (WCAG 1.4.1)
  • The live region is synchronously cleared before each announcement so repeating the same message is always re-read
  • role="alert" / role="status" set on each toast based on the resolved ariaLive level
  • NcLoadingIcon is wrapped in aria-hidden="true" so the spinner doesn't pollute announcements

Demo

Peek.18-03-2026.15-40.mp4

@skjnldsv skjnldsv self-assigned this Mar 17, 2026
@skjnldsv skjnldsv requested review from ShGKme and susnux March 17, 2026 16:46
@skjnldsv skjnldsv added bug Something isn't working 3. to review accessibility for accessibility work or changes labels Mar 17, 2026
@codecov
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 87.95181% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.66%. Comparing base (54a500a) to head (e245c3e).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
lib/toast.ts 87.95% 6 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2324       +/-   ##
===========================================
+ Coverage   43.79%   57.66%   +13.87%     
===========================================
  Files          15       15               
  Lines         427      463       +36     
  Branches       81       96       +15     
===========================================
+ Hits          187      267       +80     
+ Misses        211      171       -40     
+ Partials       29       25        -4     

☔ 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.

susnux

This comment was marked as resolved.

susnux

This comment was marked as resolved.

szaimen

This comment was marked as resolved.

@skjnldsv

This comment was marked as resolved.

@skjnldsv skjnldsv changed the title fix: make toasts accessible feat: accessible toast and drop toastify Mar 18, 2026
@skjnldsv skjnldsv requested review from susnux and szaimen March 18, 2026 14:49
@skjnldsv
Copy link
Contributor Author

I wonder if we should completely remove the toasts dependency and write it from scratch as NcToast or similar to not have to monkey patch it all the time 😅

Done @susnux 🚀

Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Copy link
Contributor

@szaimen szaimen left a comment

Choose a reason for hiding this comment

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

🐘

@susnux
Copy link
Contributor

susnux commented Mar 18, 2026

Oh wow I did not expect this to happen 😆
Did you test how it works if old + new version are used next to each other (e.g. because one app uses an old version?)

@susnux susnux dismissed their stale review March 18, 2026 15:01

outdated changes

@skjnldsv
Copy link
Contributor Author

skjnldsv commented Mar 18, 2026

Did you test how it works if old + new version are used next to each other (e.g. because one app uses an old version?)

Good call, I did not test it 🤔
EDIT: I guess they would overlap, but we rarely have two apps over the other, I think it's unlikely we face that issue.
Having simultaneously two messages dispatched by one app and one call from another app seems unlikely, no ?

@susnux
Copy link
Contributor

susnux commented Mar 18, 2026

Having simultaneously two messages dispatched by one app and one call from another app seems unlikely, no ?

I can only imagine integrations like e.g. text in files or similar.

@skjnldsv
Copy link
Contributor Author

I can only imagine integrations like e.g. text in files or similar.

image

Yeah, that seems like a very specific race condition and context to have.
Honestly I think it's fine to leave as is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review accessibility for accessibility work or changes bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Making toasts more accessible

3 participants