Automatically focus the execute button in the DacFx wizard summary screens (#6984)

* Focus piping for extension buttons

* Focus the done button when entering the summary page for DacFx wizard

* Adding internal value resets for extension-side button model.

* Correcting remark string
This commit is contained in:
Benjin Dubishar
2019-09-09 14:57:28 -07:00
committed by GitHub
parent 3e9b694e6f
commit 66cdbbb335
7 changed files with 46 additions and 2 deletions

5
src/sql/azdata.d.ts vendored
View File

@@ -3624,6 +3624,11 @@ declare module 'azdata' {
*/
hidden: boolean;
/**
* Whether the button is focused
*/
focused?: boolean;
/**
* Raised when the button is clicked
*/

View File

@@ -119,6 +119,11 @@ export class WizardModal extends Modal {
buttonElement.label = dialogButton.label;
buttonElement.enabled = requirePageValid ? dialogButton.enabled && this._wizard.pages[this._wizard.currentPage].valid : dialogButton.enabled;
dialogButton.hidden ? buttonElement.element.parentElement.classList.add('dialogModal-hidden') : buttonElement.element.parentElement.classList.remove('dialogModal-hidden');
if (dialogButton.focused) {
buttonElement.focus();
}
this.setButtonsForPage(this._wizard.currentPage);
}

View File

@@ -83,6 +83,7 @@ export class DialogButton implements azdata.window.Button {
private _label: string;
private _enabled: boolean;
private _hidden: boolean;
private _focused: boolean;
private _onClick: Emitter<void> = new Emitter<void>();
public readonly onClick: Event<void> = this._onClick.event;
private _onUpdate: Emitter<void> = new Emitter<void>();
@@ -121,6 +122,15 @@ export class DialogButton implements azdata.window.Button {
this._onUpdate.fire();
}
public get focused(): boolean {
return this._focused;
}
public set focused(focused: boolean) {
this._focused = focused;
this._onUpdate.fire();
}
/**
* Register an event that notifies the button that it has been clicked
*/
@@ -255,4 +265,4 @@ export class Wizard {
this._message = value;
this._onMessageChange.fire(this._message);
}
}
}

View File

@@ -207,6 +207,7 @@ class ButtonImpl implements azdata.window.Button {
private _label: string;
private _enabled: boolean;
private _hidden: boolean;
private _focused: boolean;
private _onClick = new Emitter<void>();
public onClick = this._onClick.event;
@@ -243,6 +244,23 @@ class ButtonImpl implements azdata.window.Button {
this._extHostModelViewDialog.updateButton(this);
}
public get focused(): boolean {
return this._focused;
}
/**
* Focuses the button when set to "true", then the internal value is immediately reset to 'undefined'.
*
* @remarks
* Because communication between ADS and extensions is unidirectional, a focus change by the user is not
* communicated to the extension. The internal value is reset to avoid inconsistent models of where focus is.
*/
public set focused(focused: boolean) {
this._focused = focused;
this._extHostModelViewDialog.updateButton(this);
this._focused = undefined;
}
public getOnClickCallback(): () => void {
return () => this._onClick.fire();
}
@@ -568,7 +586,8 @@ export class ExtHostModelViewDialog implements ExtHostModelViewDialogShape {
this._proxy.$setButtonDetails(handle, {
label: button.label,
enabled: button.enabled,
hidden: button.hidden
hidden: button.hidden,
focused: button.focused
});
}

View File

@@ -251,6 +251,7 @@ export interface IModelViewButtonDetails {
label: string;
enabled: boolean;
hidden: boolean;
focused?: boolean;
}
export interface IModelViewWizardPageDetails {

View File

@@ -133,6 +133,7 @@ export class MainThreadModelViewDialog implements MainThreadModelViewDialogShape
button.label = details.label;
button.enabled = details.enabled;
button.hidden = details.hidden;
button.focused = details.focused;
}
return Promise.resolve();