From 02dbac3b5f335fbb4d82ca6cc2d14607733660c1 Mon Sep 17 00:00:00 2001 From: Lewis Sanchez <87730006+lewis-sanchez@users.noreply.github.com> Date: Mon, 23 Aug 2021 11:26:33 -0700 Subject: [PATCH] Enable Azure Data Studio's database selector to behave like SSMS' (#16681) * Enable Azure Data Studio's database selector to behave like the one in SSMS * Revert "Enable Azure Data Studio's database selector to behave like the one in SSMS" This reverts commit d146eef998a3192f76df80794a31a45c8be7f786. * Database selector auto commits selection * Adds comment explaining change * Auto commits selected database on blur * Confirms db name changed before committing db selection * Moves changed db check to selected database method * Makes use of dbName instead of having to get value from dropdown * Code review change --- src/sql/workbench/contrib/query/browser/queryActions.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/sql/workbench/contrib/query/browser/queryActions.ts b/src/sql/workbench/contrib/query/browser/queryActions.ts index 0eb9ec2986..4e3e6de3b2 100644 --- a/src/sql/workbench/contrib/query/browser/queryActions.ts +++ b/src/sql/workbench/contrib/query/browser/queryActions.ts @@ -594,6 +594,10 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt placeholder: this._selectDatabaseString, ariaLabel: this._selectDatabaseString }); + + // Allows database selector to commit typed or pasted DB names without the need to click + // or press enter to make a selection when focus is moved away from the selector. + this._register(this._dropdown.onBlur(() => this.databaseSelected(this._dropdown.value))); this._register(this._dropdown.onValueChange(s => this.databaseSelected(s))); this._register(this._dropdown.onFocus(() => this.onDropdownFocus())); this._register(this.connectionManagementService.onConnectionChanged(params => this.onConnectionChanged(params))); @@ -648,6 +652,11 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt if (!dbName) { return; } + + if (dbName === this.getCurrentDatabaseName()) { + return; + } + if (!this._editor.input) { this.logService.error('editor input was null'); return;