Repository navigation
Make SweetAlert dialogs announce their title, hide the decorative icon, and fix confirm-button contrast - #1363
Conversation
Screen readers often heard only the decorative "!" icon and the focused confirm button when a SweetAlert2 dialog opened: the icon glyph is in the accessibility tree, and SweetAlert2 marks modal dialogs aria-live="assertive", which gets in the way of announcing the dialog name and description. Add app/util/swal.ts, a Swal.mixin with a didRender hook that hides the icon from assistive tech and drops aria-live from role="dialog" popups, and switch every sweetalert2 import in app/ to it. Call options are unchanged. The .swal2-confirm button used white on #418fde (3.38:1); use var(--primary-600) (default #1e40af, 8.72:1) instead. Fixes eclipse-pass/main#1269 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The confirm button now uses --primary-600, and the stock sample overlay set it to #e37108, so white text on it was 3.17:1, slightly worse than before. Darken the sample --primary-500 / --primary-600 to #b35400 / #8a3f00 so the button meets 4.5:1 (7.52:1) with the overlay pass-docker loads by default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jaredgalanis
left a comment
There was a problem hiding this comment.
Thanks for this — the didRender hook approach is clean and the writeup made it easy to verify. I checked the claims against the installed sweetalert2 (11.17.2) source. A few findings, roughly in order of severity:
Validation messages lose their announcement (app/util/swal.ts). The aria-live we're removing was also what announced showValidationMessage() text. In the workflow-review agreement dialog (input: 'radio' + inputValidator), the first failure is still read because focus moves to the radio, but pressing Confirm again with focus already on the input produces no focus event and no live region, so the repeat failure is silent to screen readers. Suggest makePopupAccessible also set aria-live="polite" (or role="alert") on .swal2-validation-message.
Consider Swal.on('didRender', ...) instead of the mixin option. SweetAlert2 merges options shallowly, so any future call site that passes its own didRender silently drops the a11y hook — the "call makePopupAccessible yourself" note in the PR body is the symptom. 11.17.2 has a global event API: Swal.on('didRender', makePopupAccessible) registered once applies to every popup and can't be clobbered per call. Fine as a follow-up if you'd rather not rework it here.
Possible test leak in tests/unit/util/swal-test.ts. With sweetalert2.css loaded, swal.close() removes the container only after the hide animation ends (~150ms), and the positional-args test fires with no target, mounting on document.body. A popup can outlive its test into the next seed-randomized one, and the workflow-files integration test asserts on .swal2-popup scoped to document.body, so this could add to our CI flakiness. Synchronously removing .swal2-container in afterEach (or awaiting its removal) closes the gap.
Smaller notes, none blocking:
- Confirm-button contrast now follows each deployment's --primary-600. The bundled sample overlay was audited and darkened, but an institution overlay with a light --primary-600 would land back under 4.5:1. Worth a line in the branding docs.
- Four controller unit tests (files-test.ts, detail-test.ts, new-test.ts, repositories-test.ts) still stub the dist Swal class; that works only through static inheritance into the mixin subclass and breaks if the util ever wraps fire. Stubbing the util's export is sturdier.
- Nothing enforces "new dialogs import pass-ui/util/swal". An eslint no-restricted-imports rule for sweetalert2 scoped to app/** (allowing the util and the CSS import) would make the convention stick.
Happy to approve once the validation-message announcement and the test cleanup are in.
These findings and message were written with the help of Claude.
Removing aria-live from the dialog also removed what announced
validation messages, so give .swal2-validation-message its own polite
live region.
Register makePopupAccessible once with Swal.on('didRender') instead of
a mixin option, so a call's own didRender can't drop it, and export
SweetAlert2 itself from the util. Controller tests now stub that export,
and an eslint rule keeps app code importing the util rather than
sweetalert2. public/branding.css notes the 4.5:1 requirement for
--primary-600.
Only the sample overlay's --primary-600 drives the confirm button, so
--primary-500 goes back to its original value.
In the swal unit tests, turn off the hide animation before closing, so
SweetAlert2 removes the popup and the aria-hidden it put on the page
right away, and check nothing is left behind after each test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the careful review — all good catches. Pushed fbd604e:
|
|
…#1363) # Conflicts: # app/components/workflow-review/index.gts # app/controllers/submissions/detail.ts # app/util/swal.ts # public/branding-overrides.css # tests/unit/controllers/submissions/detail-test.ts # tests/unit/util/swal-test.ts
jaredgalanis
left a comment
There was a problem hiding this comment.
Looks good! Thank you!
# Conflicts: # app/components/workflow-review/index.gts # app/controllers/submissions/detail.ts # public/branding-overrides.css # tests/unit/controllers/submissions/detail-test.ts
…ipse-pass#1301 filed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>



Summary
When a SweetAlert2 dialog opened (Files → Remove, change submitter, Review → submit, session timeout and other error dialogs), screen reader users often heard only "!" and the focused button. The title ("Are you sure?") and the description were skipped. Two things caused this. The warning/error icon glyph is in the accessibility tree. SweetAlert2 also puts
aria-live="assertive"on modal dialogs, which competes with the normal announcement of the dialog'saria-labelledby/aria-describedbywhen focus moves into it. Separately, the confirm button (I Agree, Next, Confirm, ...) was white text on#418fde, which is 3.38:1, below the 4.5:1 minimum.app/util/swal.tsregisters amakePopupAccessiblehandler on SweetAlert2's globaldidRenderevent (Swal.on('didRender', …)), so it runs on every render of every popup, includingswal.update(), and a call's owndidRendercan't replace it. The handler setsaria-hidden="true"on.swal2-icon, removesaria-livefromrole="dialog"popups (toasts keep theirs), and gives.swal2-validation-messageits ownaria-live="polite"/aria-atomic="true"region, since the dialog's live region was also what announced validation messages. The module exports SweetAlert2 itself, so the API is unchanged.sweetalert2import inapp/now usespass-ui/util/swalinstead (external-repo-review, submission-action-cell, workflow-basics, workflow-files, workflow-review, submissions/detail, submissions/new, new/files, new/repositories, error-handler). The options passed at each call site are unchanged. The// @ts-ignorecomments on those imports are gone because the helper is typed..swal2-confirminapp/styles/app.cssnow usesvar(--primary-600, #1e40af)for background and border, with white text: 8.72:1 with the default branding (was 3.38:1).public/branding-overrides.css, which pass-docker loads) set--primary-600to#e37108, which would have made the button 3.17:1. It is darkened to#8a3f00, so the button is 7.52:1 there too.tests/unit/util/swal-test.tschecks the dialog role, accessible name and description, thataria-liveis gone and the icon hidden, that this holds afterupdate(), through a nested mixin, for positionalfire(title, text, icon)calls and when a call passes its owndidRender, and that a validation message is in a polite live region. After each test it turns off the hide animation before closing, so SweetAlert2 removes the popup and itsaria-hiddenon the rest of the page right away, and it checks that nothing is left behind. The Files → Remove integration test also checks the live dialog, and the controller unit tests that stub SweetAlert2 now import it from the util.eslint.config.mjs:no-restricted-importsblocks importing anysweetalert2JS entry point (the main export or a dist bundle) inapp/(except the util), so new dialogs get the fixes. Its stylesheets, like the import inapp.ts, are still allowed.public/branding.cssnotes that overlays must keep white on--primary-600at 4.5:1 or more.Fixes eclipse-pass/main#1269
Part of eclipse-pass/main#718
How to test
.swal2-popuphasrole="dialog",aria-modal="true",aria-labelledbyandaria-describedby, and noaria-live;.swal2-validation-messagehasaria-live="polite"..swal2-iconhasaria-hidden="true".#8a3f00is 7.52:1. Without the overlay it is white on#1e40af, 8.72:1. An easy dialog to check: start a submission with no grant and press Next on Repositories ("No repositories selected"), or Files → Remove.pnpm exec ember test --path dist --filter "swal"andpnpm exec ember test --path dist --filter "workflow files".Notes
focusCancel: true.--primary-600. The bundled sample overlay is darkened here, but an institution overlay with a light--primary-600would fall back under 4.5:1, sopublic/branding.cssnow says overlays must keep white-on---primary-600at 4.5:1 or more..swal2-confirmkeeps its existing!important, so per-callconfirmButtonColorvalues are still overridden, as before.🤖 Generated with Claude Code