feat(ext): dismiss branch popovers and dialogs on blur - #22
Conversation
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.
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>
|
Thanks — this works exactly as described, and the reasoning in the description matches what I see: capture from window, the 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: 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>
|
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 |
antonarnaudov
left a comment
There was a problem hiding this comment.
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.
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: