Skip to content

Browser shouldn't steal window focus#311082

Merged
kycutler merged 1 commit intomainfrom
kycutler/browserfocus
Apr 17, 2026
Merged

Browser shouldn't steal window focus#311082
kycutler merged 1 commit intomainfrom
kycutler/browserfocus

Conversation

@kycutler
Copy link
Copy Markdown
Contributor

Fixes #311069

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 17, 2026 19:33
@kycutler kycutler self-assigned this Apr 17, 2026
@kycutler kycutler enabled auto-merge (squash) April 17, 2026 19:34
@vs-code-engineering
Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@jruales

Matched files:

  • src/vs/platform/browserView/common/browserView.ts
  • src/vs/platform/browserView/electron-main/browserView.ts
  • src/vs/platform/browserView/electron-main/browserViewMainService.ts
  • src/vs/workbench/contrib/browserView/common/browserView.ts

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a focus-stealing issue where an embedded browser view can reclaim focus from a newly created VS Code window (e.g. when creating a new window via Quick Pick), aligning browser focus behavior with expected multi-window UX.

Changes:

  • Add an optional force?: boolean parameter to the browser view focus APIs (model + service).
  • Update the Electron main-process BrowserView.focus implementation to avoid focusing the webContents unless its hosting window is already focused (unless force is set).
Show a summary per file
File Description
src/vs/workbench/contrib/browserView/common/browserView.ts Extends the workbench-facing model API to allow optional forced focus.
src/vs/platform/browserView/common/browserView.ts Extends the platform service contract with an optional force focus flag and documents its intent.
src/vs/platform/browserView/electron-main/browserViewMainService.ts Plumbs the optional force flag through the main-process service layer.
src/vs/platform/browserView/electron-main/browserView.ts Implements the new focus behavior to prevent cross-window focus stealing by default.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0

@kycutler kycutler merged commit c89a817 into main Apr 17, 2026
30 checks passed
@kycutler kycutler deleted the kycutler/browserfocus branch April 17, 2026 20:02
@vs-code-engineering vs-code-engineering bot added this to the 1.117.0 milestone Apr 17, 2026
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.

Browser steals focus from windows created via a quick pick

3 participants