Skip to content

Give the toast close button reliable Escape-to-dismiss and focus handling #151

Description

@mikewheeleer

Improve keyboard accessibility of toast notifications

Description

Toasts in components/ToastProvider.jsx can only be dismissed by clicking "Close" or waiting for the timer; there is no keyboard shortcut to dismiss, and hovering pauses the timer but focusing (keyboard equivalent of hover) does not — so a keyboard user reading a toast can have it disappear mid-read. This issue adds keyboard parity: pause on focus, dismiss on Escape, and sensible focus return.

Requirements and context

  • Repository scope: Liquifact/Liquifact-frontend only.
  • Pause/resume the auto-dismiss timer on focus/blur of the toast (mirroring the existing mouseenter/mouseleave pause/resume) so focusing a toast does not let it vanish.
  • Allow Escape to dismiss the focused toast.
  • Ensure the "Close" button and toast are reachable in a sensible tab order and that focus moves to a safe element after dismissal (no focus loss to body).
  • Keep the role="status"/aria-live="polite" region and all existing variant styling.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b a11y/toast-22-keyboard-dismiss
  • Implement changes
    • Write code in: update components/ToastProvider.jsx.
    • Write comprehensive tests in: create components/ToastProvider.keyboard.test.tsx using user-event and fake timers — assert focus pauses the timer, Escape dismisses, and focus return.
    • Add documentation: note the keyboard behaviour in README.md.
    • Add comments on the focus/blur pause parity.
    • Validate a11y: no jest-axe violations and keyboard-operable dismissal.
  • Test and commit

Test and commit

  • Run npm run lint, npm test, and npm run build.
  • Cover edge cases: focus-pause, Escape dismiss, and focus return after close.
  • Include the full npm test output.

Example commit message

fix: add escape-to-dismiss and focus pause to toast notifications

Guidelines

  • Minimum 95 percent test coverage for impacted modules.
  • Clear, reviewer-focused documentation.
  • Timeframe: 96 hours.

Community & contribution rewards

  • 💬 Join the Liquifact community on Discord for questions, reviews, and faster merges: https://discord.gg/JrGPH4V3
  • ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.

Metadata

Metadata

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions