From 7ed072c44d5a6c03f3b04a71f1ce985851a991c6 Mon Sep 17 00:00:00 2001 From: Alan Ren Date: Mon, 16 Mar 2020 11:51:57 -0700 Subject: [PATCH] do nothing if the focus is already in dialog (#9629) * do nothing if the focus is already in dialog * use document.activeElement instead --- src/sql/workbench/browser/modal/modal.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sql/workbench/browser/modal/modal.ts b/src/sql/workbench/browser/modal/modal.ts index 04000b5292..7d12d23258 100644 --- a/src/sql/workbench/browser/modal/modal.ts +++ b/src/sql/workbench/browser/modal/modal.ts @@ -501,9 +501,11 @@ export abstract class Modal extends Disposable implements IThemable { DOM.prepend(this._modalContent, (this._messageElement)); } } else { - // Set the focus manually otherwise it'll escape the dialog to something behind it - this.setInitialFocusedElement(); DOM.removeNode(this._messageElement); + // Set the focus to first focus element if the focus is not within the dialog + if (!DOM.isAncestor(document.activeElement, this._bodyContainer)) { + this.setInitialFocusedElement(); + } } }