Skip to content

feat(gallery): focus preview iframes on load so instruments play via keys - #9

Merged
wustep merged 1 commit into
mainfrom
claude/showcase-bench-keyboard-ff83ff
Jul 19, 2026
Merged

feat(gallery): focus preview iframes on load so instruments play via keys#9
wustep merged 1 commit into
mainfrom
claude/showcase-bench-keyboard-ff83ff

Conversation

@wustep

@wustep wustep commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • The showcase and candidate previews listen for QWERTY note input on their own iframe window, but the overlay focused the parent dialog — keys were dead until you clicked inside the frame. PreviewFrame now takes an autoFocus prop and focuses the iframe once its build loads, so trusted keystrokes land in the frame immediately (which also grants the user activation the preview's AudioContext needs to start sounding).
  • With focus inside the iframe the parent never sees Escape, so PreviewFrame also attaches a keydown listener to the same-origin content window (re-attached per load — navigation replaces the window) and closes the overlay via a new onEscape prop. The check defers one tick and respects defaultPrevented, so Escape peels one layer at a time: the showcase's section-zoom dialog closes first, the overlay on the next press.
  • Wired up in Dialogs: run previews and the showcase get autoFocus + onEscape; the report overlay gets onEscape (Escape after clicking into a report used to go dead).

Test plan

  • pnpm typecheck, pnpm lint, pnpm test (36/36)
  • Live in dev server: showcase overlay auto-focuses its iframe; a trusted keypress reaches the frame and the AudioContext reads running; KeyA holds/releases MIDI 60 through the instrument controller
  • Escape inside the frame closes the overlay; stays open when an inner dialog consumes Escape (preventDefault), closes on the second press
  • Deep-linked run preview (?run=…&phase=…) auto-focuses and closes on Escape

🤖 Generated with Claude Code

…keys

The showcase and candidate builds listen for computer-keyboard input on
their own iframe window, but the overlay focused the parent dialog — keys
did nothing until a click inside the frame. Focusing the iframe on load
delivers trusted keystrokes straight in (which also grants the user
activation the preview's AudioContext needs), and a same-origin listener
forwards Escape back out so the overlay still closes, one layer at a time.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stagebench Ready Ready Preview, Comment Jul 19, 2026 3:15am

Request Review

@wustep
wustep merged commit 4df837b into main Jul 19, 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