From 7ba4f424948c24c23f9953fb16a7299656a0ba71 Mon Sep 17 00:00:00 2001 From: kisantia <31145923+kisantia@users.noreply.github.com> Date: Wed, 9 Jan 2019 13:19:24 -0800 Subject: [PATCH] Moving onValidityChanged listener to showPage() so that it gets added to pages that are added to the wizard after the initial start up (#3691) --- src/sql/platform/dialog/wizardModal.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/sql/platform/dialog/wizardModal.ts b/src/sql/platform/dialog/wizardModal.ts index 1580e0f3d1..26d4448737 100644 --- a/src/sql/platform/dialog/wizardModal.ts +++ b/src/sql/platform/dialog/wizardModal.ts @@ -97,15 +97,6 @@ export class WizardModal extends Modal { messageChangeHandler(this._wizard.message); this._wizard.onMessageChange(message => messageChangeHandler(message)); - - this._wizard.pages.forEach((page, index) => { - page.onValidityChanged(valid => { - if (index === this._wizard.currentPage) { - this._nextButton.enabled = this._wizard.nextButton.enabled && page.valid; - this._doneButton.enabled = this._wizard.doneButton.enabled && page.valid; - } - }); - }); } private addDialogButton(button: DialogButton, onSelect: () => void = () => undefined, registerClickEvent: boolean = true, requirePageValid: boolean = false): Button { @@ -198,6 +189,13 @@ export class WizardModal extends Modal { let currentPageValid = this._wizard.pages[this._wizard.currentPage].valid; this._nextButton.enabled = this._wizard.nextButton.enabled && currentPageValid; this._doneButton.enabled = this._wizard.doneButton.enabled && currentPageValid; + + pageToShow.onValidityChanged(valid => { + if (index === this._wizard.currentPage) { + this._nextButton.enabled = this._wizard.nextButton.enabled && pageToShow.valid; + this._doneButton.enabled = this._wizard.doneButton.enabled && pageToShow.valid; + } + }); } private setButtonsForPage(index: number) {