fix(z-modal): catch escaped focus in modal focus trap#658
Open
ada-workbackai wants to merge 1 commit intomasterfrom
Open
fix(z-modal): catch escaped focus in modal focus trap#658ada-workbackai wants to merge 1 commit intomasterfrom
ada-workbackai wants to merge 1 commit intomasterfrom
Conversation
When focus moves to a non-focusable element (e.g., the host container or dialog element), the existing first/last boundary checks don't match, allowing focus to escape the modal. This adds a fallback that detects when focus is outside the known focusable elements and redirects it back into the modal based on tab direction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes WCAG 2.4.3 (Focus Order) by catching escaped focus in the
<z-modal>focus trap.Issue: When tabbing through modal elements, focus escapes to the
<z-modal>host element after the last interactive element, before cycling back into the modal inputs. This creates an unpredictable stop in the tab sequence that breaks focus order for keyboard and screen reader users.Solution: Added a fallback in
handleKeyDownthat detects when the active element is not in the list of known focusable elements (i.e., focus has escaped to the host or dialog container) and redirects it back to the appropriate boundary element based on tab direction.Test Plan
Evidence
View full audit details and evidence:
https://app.workback.ai/dashboard/issue/2773/
WCAG Reference:
2.4.3 Focus Order (Level A)