Skip to content

[Bug]: Closing Settings or Usage drops focus instead of returning it #38698

Closed

Description

@nibarAhmed

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. Focus something in a thread, for example the composer or a sidebar button.
  2. Open Usage (sidebar button, command palette "Open usage", or the usage.open shortcut), or open Settings.
  3. Press Esc to close it.

Expected behavior

Focus returns to where it was before the modal opened, so keyboard and screen reader users continue from the same place.

Actual behavior

Nothing has focus after closing; focus falls to the page body. A screen reader then starts reading from the top of the page, which is the thread sidebar, and the next Tab also starts from the top.

AppRouteModal, used by both Settings and Usage, sets finalFocus={false} and blurs the focused element before closing (apps/web/src/components/AppRouteModal.tsx). The comment says this avoids a focus ring on the opener after a mouse close. Restoring focus only on keyboard close, e.g. finalFocus={(closeType) => closeType === "keyboard"} as UpdateEverythingDialog does, would keep that and fix keyboard use. The thread view stays mounted behind the modal, so the opener is still there to return to. Opening from the command palette needs care: the palette has already closed, so the element to return to is the one focused before the palette opened.

Impact

Minor bug or occasional failure

Version or commit

main @ 8cf97b5

Environment

Windows 11, screen reader

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions