You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Closing Settings or Usage drops focus instead of returning it #38698
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
Focus something in a thread, for example the composer or a sidebar button.
Open Usage (sidebar button, command palette "Open usage", or the usage.open shortcut), or open Settings.
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.
Activity