Skip to content

fix(preview): exclude the panel from tab order while closed (real Shift+Tab root cause) - #10

Merged
ohernandezdev merged 1 commit into
mainfrom
fix/shift-tab-preview-focus
Jul 27, 2026
Merged

fix(preview): exclude the panel from tab order while closed (real Shift+Tab root cause)#10
ohernandezdev merged 1 commit into
mainfrom
fix/shift-tab-preview-focus

Conversation

@ohernandezdev

Copy link
Copy Markdown
Owner

Summary

Found and fixed the actual root cause of "Shift+Tab opens the file preview panel" reported on both Windows and macOS (the previous PR #8 hardened the click/Escape paths but never addressed the real trigger).

xterm.js's evaluateKeyboardEvent deliberately leaves Shift+Tab uncancelled (cancel: false) — unlike plain Tab/Enter/Escape which all set cancel: true — so app-level Shift+Tab chords (e.g. Claude Code's own plan-mode toggle) still reach the pty. That also means the browser's native reverse-tab-order focus navigation isn't suppressed.

The file-preview panel stays in the DOM (translated off-screen via CSS, not display:none, so its slide-in transition can animate), which left its Copy/Edit/Close buttons as real, always-focusable elements sitting right before the terminal panes in DOM order — exactly where Shift+Tab from the terminal lands. The buttons now start tabindex="-1" and only become tab-reachable while the panel is actually open.

Verification

Confirmed live against an isolated test build (separate Tauri identifier + CDP/Playwright), not just read from the code:

  • Before the fix: a real Shift+Tab keypress from the terminal moved focus onto #file-preview-close.
  • After the fix: it skips straight past to the next earlier focusable element (the window's own close button) — the preview panel never gets focus, never opens, and the "content shifts left" side-effect (an off-screen focused element being scrolled into view) is gone.

Test plan

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
https://claude.ai/code/session_01GHgSVKPsaWRfuJMo1rc2AN

Root cause of the "Shift+Tab opens the preview" report on both Windows and
macOS: xterm.js's evaluateKeyboardEvent deliberately leaves Shift+Tab
uncancelled (cancel: false only on that branch — plain Tab, Enter, and
Escape all set it true) so app-level Shift+Tab chords, like Claude Code's
own plan-mode toggle, still reach the pty. That also means the browser's
native reverse-tab-order focus navigation runs uninterrupted.

The file-preview panel stays in the DOM (translated off-screen) rather
than display:none so its slide-in CSS transition can animate, which left
its Copy/Edit/Close buttons real, always-focusable elements sitting right
before the terminal panes in DOM order — exactly where Shift+Tab from the
terminal would land. Confirmed live: before this fix, real Shift+Tab
moved focus onto #file-preview-close; after, it skips straight to the
next earlier focusable element (the window's own close button).

Buttons now start tabindex="-1" and only become tab-reachable while the
panel is actually open, so Shift+Tab from the terminal can never land on
them (and can't scroll the off-screen panel into view either).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GHgSVKPsaWRfuJMo1rc2AN
@ohernandezdev
ohernandezdev merged commit 4422bbf into main Jul 27, 2026
3 checks passed
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.

1 participant