do nothing if the focus is already in dialog (#9629)

* do nothing if the focus is already in dialog

* use document.activeElement instead
This commit is contained in:
Alan Ren
2020-03-16 11:51:57 -07:00
committed by GitHub
parent 0405658be7
commit 7ed072c44d

View File

@@ -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();
}
}
}