Fix command palette auto-close when focus was in inline chat (#291560)

* Initial plan

* Fix command palette auto-close when focus was in inline chat

Move editor focus logic from InlineChatAffordance into
InlineChatInputWidget._hide() and only focus editor when
focus is still within the editor's DOM. This prevents
stealing focus from command palette when it opens.

Co-authored-by: jrieken <1794099+jrieken@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jrieken <1794099+jrieken@users.noreply.github.com>
This commit is contained in:
Copilot
2026-01-29 14:20:25 +00:00
committed by GitHub
parent 7624fc34ef
commit b488ab464f
2 changed files with 5 additions and 1 deletions
@@ -111,7 +111,6 @@ export class InlineChatAffordance extends Disposable {
const pos = this._inputWidget.position.read(r);
if (pos === null) {
this._menuData.set(undefined, undefined);
this._editor.focus();
}
}));
}
@@ -278,6 +278,11 @@ export class InlineChatInputWidget extends Disposable {
* Hide the widget (removes from editor but does not dispose).
*/
private _hide(): void {
// Focus editor if focus is still within the editor's DOM
const editorDomNode = this._editorObs.editor.getDomNode();
if (editorDomNode && dom.isAncestorOfActiveElement(editorDomNode)) {
this._editorObs.editor.focus();
}
this._position.set(null, undefined);
this._showStore.clear();
}