Repository navigation
fix: dismiss stuck browser address bar autocomplete on webview click - #5769
AmethystLiang merged 2 commits into
Conversation
Electron webview guests never dispatch outside pointer events to the renderer, so the address bar history dropdown could stay open after clicking the page. Close it on guest focus, window blur, and Escape. Co-authored-by: Cursor <[email protected]>
|
Ready to review this PR? Stage has broken it down into 3 individual chapters for you:
Chapters generated by Stage for commit 9dbe979 on Jun 19, 2026 5:57am UTC. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
In 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/renderer/src/components/browser-pane/BrowserAddressBar.tsx (1)
17-17: ⚡ Quick winPrefer the React 19
RefObjecttype for this mutable ref prop.React 19 makes refs mutable through
RefObject, and the provided React 19 docs call out the mutable-ref type changes. Typing this public prop asMutableRefObjectrisks drifting from the installed React 19 types.♻️ Proposed ref type update
- dismissSuggestionsRef?: React.MutableRefObject<(() => void) | null> + dismissSuggestionsRef?: React.RefObject<(() => void) | null>src/renderer/src/components/browser-pane/BrowserPane.tsx (1)
3507-3509: ⚡ Quick winAdd a short “why” comment to the webview-focus bridge.
This listener is driven by Electron guest-process focus semantics, which are not obvious from
focusalone.📝 Proposed comment
+ // Why: focus inside the guest process never reaches Radix outside-click + // handlers, so bridge the webview focus event back to the address bar. const dismissAddressBarSuggestions = (): void => { dismissAddressBarSuggestionsRef.current?.() }As per coding guidelines, “When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.”
Also applies to: 3745-3745
Source: Coding guidelines
src/renderer/src/components/browser-pane/BrowserAddressBar.test.tsx (1)
171-179: ⚡ Quick winAssert the dropdown actually closes.
The regression is the stuck suggestions popover; this test currently verifies value restoration but would miss a regression where the listbox remains mounted.
✅ Proposed assertion
await act(async () => { webview.dispatchEvent(new FocusEvent('focusin', { bubbles: true })) }) + expect(document.querySelector('`#browser-history-listbox`')).toBeNull() expect(container.querySelector('[data-current-address-value="true"]')?.textContent).toBe( 'local' )
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d9e85d5d-a5cb-4b28-8439-d27bd98bad57
📒 Files selected for processing (3)
src/renderer/src/components/browser-pane/BrowserAddressBar.test.tsxsrc/renderer/src/components/browser-pane/BrowserAddressBar.tsxsrc/renderer/src/components/browser-pane/BrowserPane.tsx
AmethystLiang
left a comment
There was a problem hiding this comment.
Thanks, this fixes the webview focus boundary cleanly.
I added regression coverage for the remaining claimed dismiss paths:
- window blur restores the typed query and closes suggestions
- Escape through the native window listener restores the typed query and closes suggestions
Verified with targeted tests, full typecheck/lint, and Electron validation of the real browser pane: suggestions open from history, clicking the webview focuses the guest and removes the popover.
…tablyai#5769) * fix: dismiss stuck browser address bar autocomplete on webview click Electron webview guests never dispatch outside pointer events to the renderer, so the address bar history dropdown could stay open after clicking the page. Close it on guest focus, window blur, and Escape. Co-authored-by: Cursor <[email protected]> * test: cover browser address bar dismiss paths --------- Co-authored-by: Cursor <[email protected]> Co-authored-by: Jinjing <[email protected]>
Summary
Clicking the loaded page in a browser tab could leave the address bar history dropdown stuck under the toolbar, with no way to dismiss it except refocusing the address bar and pressing Escape. The dropdown now closes when you click into the page, switch away from Orca, or press Escape.
Electron
<webview>guests run in a separate process, so clicks inside the page never reach the renderer's outside-click handlers that Radix popovers rely on. The fix listens for focus entering the webview guest, window blur, and Escape — matching the pattern already used by the browser import hint popover — and wires a backup dismiss path fromBrowserPanewhen the webview element receives focus.Demo
Before
CleanShot.2026-06-18.at.22.18.57.mp4
After
CleanShot.2026-06-18.at.22.19.38.mp4
Test plan
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/browser-pane/BrowserAddressBar.test.tsx