Skip to content

webui: restore focus when dismissing modal sheets - #1202

Merged
edwin-zvs merged 1 commit into
mainfrom
fix-webui-overlay-focus-1074
Aug 4, 2026
Merged

webui: restore focus when dismissing modal sheets#1202
edwin-zvs merged 1 commit into
mainfrom
fix-webui-overlay-focus-1074

Conversation

@edwin-zvs

Copy link
Copy Markdown
Contributor

Summary

Fixes #1074: closing a web UI modal sheet (Rename / Settings / Close-session / New-session) no longer drops keyboard focus to <body>.

  • Capture the invoker on open; restore it on every close path (Escape, Cancel, backdrop, primary action).
  • If the invoker is gone or unfocusable, fall back to focusActiveSurface() so typing lands on the terminal / composer / playbook.
  • On touch layouts, the fallback prefers the visible composer over a silent xterm helper-textarea focus.
  • Successful session create focuses the new session surface instead of the + button.
  • Deliberate view-mode toggles leave a typing destination (chat → composer; terminal respects touch keyboard policy then composer fallback).
  • Spec: specs/0189-webui-overlay-focus-restore.md
  • e2e: web_smoke asserts rename/settings/close-session restore + gone-invoker fallback

Test plan

  • cargo build in worktree
  • cargo test -p construct-e2e --test web_smoke
  • Manual: open Rename → Escape → type; focus should not be on body
  • Manual: open Settings from usage badge → backdrop click → badge refocused
  • Manual: create session → type immediately into the new surface
  • Manual: toggle chat/terminal → type reaches expected surface

Closing rename/settings/close-session/new-session only hid the sheet, so
keyboard focus fell to <body> and the next keystroke went nowhere.
Record the invoker on open, restore it on close, and fall back to the
active surface (composer preferred on touch) when the invoker is gone.

Also land focus after successful session create and deliberate view-mode
toggles. Spec 0189; regression coverage in web_smoke. Fixes #1074.
@edwin-zvs
edwin-zvs merged commit dde9c5c into main Aug 4, 2026
1 of 2 checks passed
@edwin-zvs
edwin-zvs deleted the fix-webui-overlay-focus-1074 branch August 4, 2026 05:10
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.

web UI: closing a modal sheet drops keyboard focus to <body>

1 participant