| Posted by: WUICTeam - Monday, November 16, 2026 9:01:54 AM |
|---|
| [b]Question[/b] In a wizard built with [c]wuic-parametric-dialog[/c] and [c]isWizard=true[/c], Next blocks me when a field of the current step is invalid. Going back with Previous does not. Is that expected, and how do I validate the step when the user goes back too? [b]Answer[/b] Yes, it is expected: only Next validates the current step. Previous moves back without checking anything. [b]Why[/b] The two buttons call the same navigation method on the datasource with different flags. [c]selectNextVisibleTab()[/c] calls [c]setSelectedTab(tabName)[/c] with validation on: it evaluates the validation rules of the columns of the current step, and if one fails it shows a warning toast and stays on the step. [c]selectPreviousVisibleTab()[/c] calls [c]setSelectedTab(tabName, false, true)[/c], where the third argument is [c]skipValidation[/c]. The idea is that going back to fix something should never be blocked by what you have not filled in yet. Hidden steps are skipped in both directions. The last gate is the Complete button: its [c]disable_callback[/c] is [c]return !datasource.canCompleteWizard()[/c], which keeps it disabled while any validation rule on a visible step is marked invalid. [b]Validating on Previous too[/b] Override the [c]action_callback[/c] of the Previous custom action and call [c]setSelectedTab[/c] yourself, leaving [c]skipValidation[/c] at its default. In the callback the datasource is available as [c]datasource[/c]: [code]const tabs = datasource.metaInfo.dataTabs.filter(t => !t.hidden); const i = tabs.findIndex(t => t.selected); if (i > 0) { datasource.setSelectedTab(tabs[i - 1].tabName); }[/code] [b]Avoid[/b] calling [c]setSelectedTab[/c] with a hidden step's name or index without [c]allowHidden[/c]: it returns [c]false[/c] and nothing happens. Keep the [c]disable_callback[/c] as [c]return !datasource.hasPreviousVisibleTab[/c] so the button still disables itself on the first step. [url=https://wuic-framework.com/docs/wizard]Documentation: Wizard[/url] |