diff --git a/src/sql/workbench/browser/modal/modal.ts b/src/sql/workbench/browser/modal/modal.ts index 7d12d23258..4bac8afa71 100644 --- a/src/sql/workbench/browser/modal/modal.ts +++ b/src/sql/workbench/browser/modal/modal.ts @@ -345,8 +345,6 @@ export abstract class Modal extends Disposable implements IThemable { this._modalBodySection.querySelectorAll(tabbableElementsQuerySelector) : this._bodyContainer.querySelectorAll(tabbableElementsQuerySelector); - this._focusedElementBeforeOpen = document.activeElement; - if (focusableElements && focusableElements.length > 0) { (focusableElements[0]).focus(); } @@ -356,6 +354,7 @@ export abstract class Modal extends Disposable implements IThemable { * Shows the modal and attaches key listeners */ protected show() { + this._focusedElementBeforeOpen = document.activeElement; this._modalShowingContext.get()!.push(this._staticKey); DOM.append(this.layoutService.container, this._bodyContainer); this.setInitialFocusedElement(); @@ -396,14 +395,18 @@ export abstract class Modal extends Disposable implements IThemable { protected hide() { this._modalShowingContext.get()!.pop(); this._bodyContainer.remove(); - if (this._focusedElementBeforeOpen) { - this._focusedElementBeforeOpen.focus(); - } this._keydownListener.dispose(); this._resizeListener.dispose(); this._telemetryService.createActionEvent(TelemetryKeys.TelemetryView.Shell, TelemetryKeys.ModalDialogClosed) .withAdditionalProperties({ name: this._name }) .send(); + this.restoreKeyboardFocus(); + } + + private restoreKeyboardFocus() { + if (this._focusedElementBeforeOpen) { + this._focusedElementBeforeOpen.focus(); + } } /** diff --git a/src/vs/workbench/browser/workbench.contribution.ts b/src/vs/workbench/browser/workbench.contribution.ts index 224bfe30e3..ea7b5d9b34 100644 --- a/src/vs/workbench/browser/workbench.contribution.ts +++ b/src/vs/workbench/browser/workbench.contribution.ts @@ -223,7 +223,7 @@ import { workbenchConfigurationNodeBase } from 'vs/workbench/common/configuratio }, 'workbench.view.alwaysShowHeaderActions': { 'type': 'boolean', - 'default': false, + 'default': true, // {{SQL CARBON EDIT}} - change the default value from false to true. 'description': nls.localize('viewVisibility', "Controls the visibility of view header actions. View header actions may either be always visible, or only visible when that view is focused or hovered over.") }, 'workbench.view.experimental.allowMovingToNewContainer': {