Fix enable/disable script button behavior (#24437)

This commit is contained in:
Barbara Valdez
2023-09-15 12:43:50 -07:00
committed by GitHub
parent 7e39174f63
commit 600f59eae6

View File

@@ -63,13 +63,16 @@ export abstract class ScriptableDialogBase<OptionsType extends ScriptableDialogO
protected abstract get isDirty(): boolean; protected abstract get isDirty(): boolean;
protected override onFormFieldChange(): void { protected override onFormFieldChange(): void {
this._scriptButton.enabled = this.isDirty; this.updateScriptButtonState();
this.dialogObject.okButton.enabled = this.isDirty; this.dialogObject.okButton.enabled = this.isDirty;
} }
protected override async initialize(): Promise<void> { protected override async initialize(): Promise<void> {
await this.initializeData(); await this.initializeData();
await this.initializeUI(); await this.initializeUI();
this.disposables.push(this.modelView.onValidityChanged(() => {
this.updateScriptButtonState();
}));
} }
protected override updateLoadingStatus(isLoading: boolean, loadingText?: string, loadingCompletedText?: string): void { protected override updateLoadingStatus(isLoading: boolean, loadingText?: string, loadingCompletedText?: string): void {
@@ -131,4 +134,8 @@ export abstract class ScriptableDialogBase<OptionsType extends ScriptableDialogO
this.updateLoadingStatus(false, localizedConstants.GeneratingScriptText, localizedConstants.GeneratingScriptCompletedText); this.updateLoadingStatus(false, localizedConstants.GeneratingScriptText, localizedConstants.GeneratingScriptCompletedText);
} }
} }
private updateScriptButtonState(): void {
this._scriptButton.enabled = this.isDirty && this.modelView.valid;
}
} }