fix(site): re-focus terminal on window focus for iframe embedding#22865
Open
lucasoeth wants to merge 1 commit intocoder:mainfrom
Open
fix(site): re-focus terminal on window focus for iframe embedding#22865lucasoeth wants to merge 1 commit intocoder:mainfrom
lucasoeth wants to merge 1 commit intocoder:mainfrom
Conversation
When the terminal page is embedded in an iframe (e.g. the Tasks view or third-party dashboards), switching between tabs causes the terminal to lose keyboard focus. The parent page can call `iframe.contentWindow.focus()` which fires the window "focus" event, but xterm.js does not automatically re-focus its textarea in response. Add a window "focus" event listener that calls `terminal.focus()`, allowing the terminal to receive keyboard input immediately after a tab switch without requiring an extra click. Fixes coder#21149 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
I have read the CLA Document and I hereby sign the CLA Lucas Soeth seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
samedii
approved these changes
Mar 9, 2026
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.
Description
When the terminal page is embedded in an iframe (e.g. the Tasks view or third-party dashboards), switching between tabs causes the terminal to lose keyboard focus. The user has to click inside the terminal to start typing again.
The parent page can call
iframe.contentWindow.focus()which fires thewindowfocusevent inside the iframe, but xterm.js does not listen for this event and does not re-focus its hidden textarea in response.This adds a
windowfocus event listener that callsterminal.focus(), so the terminal receives keyboard input immediately after a tab switch.Impact
contentWindow.focus()Changes
One
useEffectadded toTerminalPage.tsx(~10 lines).Testing