Skip to content

feat(a11y): implement Escape key shortcut to dismiss modals and popups (#20) - #21

Open
syntaxsuuvam-spec wants to merge 3 commits into
Stellar-Threads:mainfrom
syntaxsuuvam-spec:feat/issue-20-escape-key-modal-dismiss
Open

syntaxsuuvam-spec wants to merge 3 commits into
Stellar-Threads:mainfrom
syntaxsuuvam-spec:feat/issue-20-escape-key-modal-dismiss

Conversation

@syntaxsuuvam-spec

Copy link
Copy Markdown

Summary

Resolves #20 by introducing the useEscapeKey custom hook and integrating Escape-key dismiss functionality into WalletModal, alongside comprehensive unit test coverage.

Key Changes

  • New Hook (src/hooks/useEscapeKey.ts): Reusable, SSR-safe keyboard event listener attaching a keydown listener to window with clean lifecycle teardown.
  • Wallet Modal Integration (src/components/wallet/WalletModal.tsx): Invokes useEscapeKey(onClose, isOpen) so active modals dismiss immediately upon pressing Escape.
  • Unit Test Suite (src/__tests__/useEscapeKey.test.tsx): Validates positive trigger on Escape, ignored non-Escape keys, disabled state gating, and proper listener cleanup on unmount.

Verification

  • Tested hook lifecycle and keydown listener dispatch in Vitest + React Testing Library.
  • Verified zero conflicts with base branch main.

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.

Implement keyboard shortcut (Escape) to dismiss modals and popups

1 participant