Fix enable/disable script button behavior (#24437) (#24450)

This commit is contained in:
Barbara Valdez
2023-09-15 14:58:27 -07:00
committed by GitHub
parent e53551ba03
commit cc42d842fa

View File

@@ -63,13 +63,16 @@ export abstract class ScriptableDialogBase<OptionsType extends ScriptableDialogO
protected abstract get isDirty(): boolean;
protected override onFormFieldChange(): void {
this._scriptButton.enabled = this.isDirty;
this.updateScriptButtonState();
this.dialogObject.okButton.enabled = this.isDirty;
}
protected override async initialize(): Promise<void> {
await this.initializeData();
await this.initializeUI();
this.disposables.push(this.modelView.onValidityChanged(() => {
this.updateScriptButtonState();
}));
}
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);
}
}
private updateScriptButtonState(): void {
this._scriptButton.enabled = this.isDirty && this.modelView.valid;
}
}