Skip to content

Bug: Dialogs and the command palette do not return focus to their trigger on close (focus falls to <body>) — WCAG 2.4.3 #1988

Closed

Description

@yannickmonney

What happened?

Programmatically-opened overlays do not restore keyboard focus to the control that opened them; on close (Escape or the X button) document.activeElement becomes <body>. A keyboard/screen-reader user is dumped at the top of the page and loses their place. Reproduced across the change-password dialog, the governance DSAR & legal-hold dialogs, the chat Export & Share dialogs, and the Cmd/Ctrl+K command palette (each 2/2 runs).

Steps to reproduce

  1. Open any of: Account → Change password; Governance → File erasure request / Place legal hold; chat header → Export / Share; Cmd/Ctrl+K palette.
  2. Close via Escape or the X.
  3. document.activeElement is <body>, not the trigger.

Expected behavior

On close, focus returns to the control that opened the overlay (Radix Dialog does this when given a DialogTrigger).

Affected service

Platform (web app)

Version or commit

cd13268b8

Browser and OS

Headless Chrome (Playwright) on macOS

Relevant log output / evidence

Live page.evaluate readbacks: change-password, DSAR, legal-hold, export, share, palette all return {tag:'BODY'} after close (focus WAS correctly trapped while open).

Root cause. These overlays are opened programmatically via useState without the shared Dialog's trigger prop (services/platform/app/components/ui/dialog/dialog.tsx — onCloseAutoFocus is only handled when preventCloseAutoFocus is set), so Radix has no trigger to restore to. The command palette (packages/ui/src/components/search/search-command.tsx) has the same gap.

Fix. Capture the previously-focused element on open and refocus it on close (or pass a real trigger / set onCloseAutoFocus to refocus the opener) in the Dialog primitive and SearchCommand.


Filed by an automated deep manual-QA sweep (wave 2) on a local hermetic stack (commit cd13268b8, mode-A mock LLM, headless Chrome). Reproduced before filing.

Activity

  1. added
    priority: medium
    bug
    service: platform
    automated
    on Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    automatedbugpriority: mediumservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions