fix(web): close menus when clicking into the browser tab#11148

merged1
main
GitHub fork: fix/webview-click-dismisses-menus
openedSep 10, 2026byGGigioxx
View on GitHubTwo-way sync enabledPR last imported 22d ago

In the desktop app, opening the right panel's "+" surface menu and then clicking the page inside the browser tab left the menu open. Electron delivers that click to the guest <webview>, so the host document only sees a webview focus event and never the pointerdown that Base UI's outside-press dismissal listens for. The browser toolbar's "Preview menu" had the same problem.

The hosted webview now replays a pointerdown on itself whenever it gains focus. Every menu and popover already dismisses on an outside press, so no per-menu wiring is needed.

Reproduced and verified in the dev desktop app over CDP: with the surface menu open, clicking inside the loaded page previously kept it open (active element WEBVIEW, no pointer events on the host). After the change the same click closes the surface menu and the toolbar menu. The HostedBrowserWebview test, web typecheck, and scoped lint and format checks pass; Codex review of the commit found no regressions.

Fixes #11137.

Built with Claude Fable 5.1 in Claude Code through T3 Code.

Summary by CodeRabbit

  • Bug Fixes
    • Host popups and menus now dismiss correctly when focus moves into the hosted webview.

Checks

18 successful Β· 7 skipped
All checks passed
dc280ea

Added 1 commit

  • fix(web): close menus when clicking into the browser tabdc280ea
Synced from GitHub

Bugbot is paused β€” on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

Synced from GitHub

Approvability

Verdict: Approved at dc280ea

Macroscope's review found this PR approvable β€” This is a small, self-contained UI bug fix that closes existing host menus when an embedded browser gains focus. The change is limited to one component, has paired event-listener cleanup, and introduces no broader capability or sensitive configuration change.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 9ff0eceb-4c11-4559-b551-d124126d5f53

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between c52b8d96e4b34201f19b5e5bb12c6b2a77bfaa9a and dc280ea3fb2bf350d336b6b70fa2f30c4dc6dad4.

πŸ“’ Files selected for processing (1)
  • apps/web/src/browser/HostedBrowserWebview.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


πŸ“ Walkthrough

Walkthrough

The hosted webview now dispatches a bubbling pointerdown event when it receives focus. The handler is registered with the webview lifecycle and removed during cleanup.

Changes

Hosted webview popup dismissal

Layer / File(s)Summary
Focus pointer dispatch
apps/web/src/browser/HostedBrowserWebview.tsx
The hosted webview dispatches a bubbling mouse pointerdown event on focus so host popups and menus can dismiss. The handler is removed during effect cleanup.

Suggested reviewers: juliusmarminge, t3dotgg

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Severity of issue fixed: Low

Merge Risk: βšͺ Minimal Β· up to dc280

The change addresses the reported menu-dismissal behavior without introducing a current merge-blocking risk.

πŸš₯ Pre-merge checks | βœ… 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
βœ… Passed checks (4 passed)
Check nameStatusExplanation
Title checkβœ… PassedThe title clearly describes the main change: closing menus when clicking inside the browser tab.
Description checkβœ… PassedThe description explains the problem, implementation, verification, and UI effect. It includes before-and-after screenshots and remains focused. It does not use the template headings or checklist form…
Linked Issues checkβœ… PassedThe change directly addresses issue #11137 by replaying a bubbling pointerdown event when the hosted webview gains focus. This enables existing outside-press dismissal and closes the new-tab selector …
Out of Scope Changes checkβœ… PassedThe pull request contains one focused change in HostedBrowserWebview.tsx. The change supports the linked issue and does not introduce unrelated behavior or files.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.