feat(gallery): focus preview iframes on load so instruments play via keys - #9
Merged
Merged
Conversation
…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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PreviewFramenow takes anautoFocusprop 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).PreviewFramealso attaches a keydown listener to the same-origin content window (re-attached per load — navigation replaces the window) and closes the overlay via a newonEscapeprop. The check defers one tick and respectsdefaultPrevented, so Escape peels one layer at a time: the showcase's section-zoom dialog closes first, the overlay on the next press.Dialogs: run previews and the showcase getautoFocus+onEscape; the report overlay getsonEscape(Escape after clicking into a report used to go dead).Test plan
pnpm typecheck,pnpm lint,pnpm test(36/36)running;KeyAholds/releases MIDI 60 through the instrument controller?run=…&phase=…) auto-focuses and closes on Escape🤖 Generated with Claude Code