Skip to content

fix(z-modal): ensure close button appears first in focus order#637

Open
ada-workbackai wants to merge 2 commits intomasterfrom
workbackai/fix/wcag-2.4.3-modal-focus-order
Open

fix(z-modal): ensure close button appears first in focus order#637
ada-workbackai wants to merge 2 commits intomasterfrom
workbackai/fix/wcag-2.4.3-modal-focus-order

Conversation

@ada-workbackai
Copy link
Copy Markdown
Contributor

Summary

Fixes WCAG 2.4.3 (Focus Order) by ensuring the modal close button receives focus before content buttons, matching the visual order.

Issue: The modal close button in shadow DOM appeared last in the keyboard tab sequence (CONTINUA → INDIETRO → Close button) despite being visually positioned first in the header. This violated WCAG 2.4.3 because the focus order didn't preserve the meaning conveyed by the visual layout.

Solution: Modified the Tab key handler to explicitly manage focus order based on the focusableElements array, which correctly places shadow DOM elements (close button) before light DOM elements (content buttons). The focus sequence now matches the visual order: Close button → CONTINUA → INDIETRO.

Test Plan

  • Opened modal on registration flow (testmy.zanichelli.it/registrazione/docente)
  • Verified close button now receives focus first when pressing Tab
  • Verified Tab cycles through: Close button → CONTINUA → INDIETRO → Close button
  • Verified Shift+Tab moves backward through the same sequence
  • Verified focus wraps correctly at boundaries

Evidence

View before/after screenshots and full audit details:
https://app.workback.ai/dashboard/issue/5159/


WCAG Reference:
2.4.3 Focus Order (Level A)

@francescochiapella
Copy link
Copy Markdown
Collaborator

@ada-workbackai eslint and prettier failed, please fix it

The modal close button in shadow DOM was appearing last in the tab
sequence instead of first, violating WCAG 2.4.3 (Focus Order). The
browser's natural tab order placed light DOM content before shadow DOM
elements, causing keyboard users to encounter content buttons before
the close button, despite the close button being visually positioned
first in the header.

Modified the Tab key handler to explicitly manage focus order based on
the focusableElements array, which correctly places shadow DOM elements
(close button) before light DOM elements (content buttons). This ensures
the focus sequence matches the visual order: close button → content buttons.
Address eslint padding-line-between-statements rule and prettier
formatting in the focus order handler.
@ada-workbackai ada-workbackai force-pushed the workbackai/fix/wcag-2.4.3-modal-focus-order branch from 055e71c to 00705f8 Compare April 20, 2026 14:44
@ada-workbackai
Copy link
Copy Markdown
Contributor Author

Pushed changes to fix the lint failures:

  • Fixed eslint padding-line-between-statements error (added required blank line before return)
  • Fixed prettier formatting

Also rebased on latest master.

Ready for another look when you have a chance.

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