Skip to content

feat(ui): trap focus in sheets and restore focus on close (closes #14) - #18

Open
NePreby wants to merge 2 commits into
Flow-Pulse:mainfrom
NePreby:feat/sheet-focus-trap-accessibility
Open

NePreby wants to merge 2 commits into
Flow-Pulse:mainfrom
NePreby:feat/sheet-focus-trap-accessibility

Conversation

@NePreby

@NePreby NePreby commented Nov 6, 2026

Copy link
Copy Markdown

Summary

Closes #14.

Implements keyboard focus management and trap for Sheet dialogs:

  • Focus on open: Automatically saves the triggering element (document.activeElement) and moves keyboard focus into the first focusable element inside the sheet container.
  • Tab cycle trap: Traps keyboard navigation within the dialog container using handleFocusTrap (FOCUSABLE_SELECTOR). Pressing Tab wraps from the last interactive element back to the first; pressing Shift+Tab wraps from the first back to the last.
  • Focus restoration: Restores focus to the original triggering button/element when the sheet closes via Escape, backdrop click, or close button.
  • Unit test suite: Added comprehensive unit tests in src/lib/__tests__/focus.test.ts covering Tab cycle wrap, Shift+Tab cycle wrap, outside focus handling, and non-Tab pass-through. Verified with npx tsc -b and npx vitest run (30/30 passed).

Payout Wallet:

  • TRX Tron (TRC20): TMqmJjRgVS21NL2eFtfyHciTxvE4BqGmEv

This branch has not been deployed

No deployments
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.

Accessibility pass: keyboard focus trap in sheets

1 participant