diff --git a/src/sql/workbench/browser/modal/modal.ts b/src/sql/workbench/browser/modal/modal.ts index b0a7076377..dcca096f1a 100644 --- a/src/sql/workbench/browser/modal/modal.ts +++ b/src/sql/workbench/browser/modal/modal.ts @@ -612,8 +612,11 @@ export abstract class Modal extends Disposable implements IThemable { protected set messagesElementVisible(visible: boolean) { if (visible) { if (this._useDefaultMessageBoxLocation) { - DOM.prepend(this._modalContent!, this._messageElement!); - this.setInitialFocusedElement(); + // To avoid stealing focus from the user, only reset the keyboard focus when the message is not currently visible. + if (!this._messageElement!.parentNode) { + DOM.prepend(this._modalContent!, this._messageElement!); + this.setInitialFocusedElement(); + } } } else { // only do the removal when the messageElement has parent element.