Skip to content

feat(ext): dismiss branch popovers and dialogs on blur - #22

Merged
antonarnaudov merged 3 commits into
GitStudioHQ:mainfrom
wanzirong:feat/blur-dismiss-popovers
Aug 20, 2026
Merged

feat(ext): dismiss branch popovers and dialogs on blur#22
antonarnaudov merged 3 commits into
GitStudioHQ:mainfrom
wanzirong:feat/blur-dismiss-popovers

Conversation

@wanzirong

@wanzirong wanzirong commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Replaces the previously-closed #15 (its head branch was force-pushed past the state GitHub had recorded).

Branch popovers and action menus close on any click outside the webview — including clicks in the editor or other areas, which never reach the webview. Blur is the only signal that focus left the webview, so it is treated as a click-outside, matching JetBrains' dismissal behavior for popovers.

Blur does not bubble, but capture starts at window, so a click INSIDE a menu (focus moving off the focused row) fires the dismiss handler too. The handler checks document.hasFocus() in a setTimeout — a focus move that stays in the webview is not treated as a click outside — and guards on the element still existing, so a stale callback cannot close a menu that was already dismissed.

The dialogs (ref picker, branch name input) deliberately do NOT dismiss on blur: blur also fires when you switch to another application, and alt-tabbing away must not lose a half-typed name. They close on Escape and backdrop-click only, as before.

Behavior notes:

  • Dialogs answer "cancelled" on Escape / backdrop-click; destructive confirms still only act on the explicit OK.
  • Popovers also close on Escape, as before.

Clicks in the editor/main area never reach a webview, so a click outside
the popover didn't dismiss it. Blur is the only signal that focus left the
webview, so treat it like a click-outside: branch menu, branch actions, and
all custom dialogs now close on blur, matching JetBrains. Dialogs answer
'cancelled' on blur; destructive confirms still only act on the explicit OK.
blur does not bubble, but capture starts at window, so a click inside a
menu or dialog (focus moving off the focused row/input) fired the dismiss
handler too. Check document.hasFocus() in a setTimeout so a focus move
that stays in the webview is not treated as a click outside, and guard on
the element still existing so a stale callback cannot close a dialog that
was already answered — or a newer one.
antonarnaudov added a commit that referenced this pull request Aug 19, 2026
The request comes from the status bar, so focus is not in the webview when the
menu appears — it opened unfocused, and the first arrow key went nowhere.

Found while reviewing #22, which dismisses menus on blur. I suspected the two
would collide and the status-bar button would look dead again, and could not
construct a sequence where that actually happens: blur fires on a window LOSING
focus, the webview is not focused when the status bar is clicked, and the open
happens after any blur rather than before. The synthetic test that "reproduced"
it was dispatching an event the real flow does not produce. So this is the
keyboard fix it always was, and not the interaction fix I briefly thought.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@antonarnaudov

Copy link
Copy Markdown
Contributor

Thanks — this works exactly as described, and the reasoning in the description matches what I see: capture from window, the hasFocus() check in a setTimeout, and the null guards. Merges cleanly on top of 1.9.0.

One thing before I merge. Blur also fires when you switch to another application, not just when you click elsewhere in the editor. So alt-tabbing to a browser to copy a branch name and coming back loses a half-typed dialog:

typed:                feature/half-typed
after switching away: dialog gone

Menus should dismiss — that part is right and matches JetBrains. But JetBrains dismisses on clicks within the IDE; it keeps dialogs when you leave the app. Losing a popover costs nothing; losing typed input does.

Would you be up for narrowing it to the popovers — branch menu and action menu keep the blur dismissal, dialogs keep Escape and backdrop-click only? Happy to take it as-is and follow up myself if you'd rather.

…popovers

Blur also fires when switching to another app, so a half-typed ref name or
branch name was lost. Branch menu and action menu keep blur dismissal
(popovers match JetBrains), but the dialogs keep typed input across an
alt-tab: Escape and backdrop-click are the only close paths again.

Co-Authored-By: Claude <noreply@anthropic.com>
@wanzirong

Copy link
Copy Markdown
Contributor Author

Done — narrowed to the popovers. Branch menu and action menu keep blur dismissal; the dialogs (ref picker, branch name input) now dismiss only on Escape and backdrop click, so alt-tabbing away mid-input preserves what you typed. The hasFocus()-in-setTimeout guard now only serves the popovers, and the PR description is updated to match.

@antonarnaudov antonarnaudov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verified: the blur handlers are now scoped to the branch and action popovers, and no dialog code changed — alt-tabbing away mid-input keeps what you typed. CI is green on all three runners and the suite passes on the branch. Merging.

@antonarnaudov
antonarnaudov merged commit 7efb76f into GitStudioHQ:main Aug 20, 2026
4 checks passed
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.

2 participants