Skip to content

Commit db77248

Browse files
Merge branch 'main' into dev
2 parents c1a7c73 + d5a1168 commit db77248

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wdns/vuetify-stepper-form",
3-
"version": "1.2.3",
3+
"version": "1.2.7",
44
"description": "The Vuetify Stepper Form plugin provides a structured way to create multi-step forms using Vue 3, TypeScript, and Vuetify. It features a stepper layout that allows users to navigate between steps with form validation. The plugin is customizable and streamlines building dynamic, interactive forms that guide users through sequential steps.",
55
"private": false,
66
"publishConfig": {

src/plugin/VStepperForm.vue

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,25 @@ function removePageError(pageIndex: number): void {
531531
currentPageHasErrors.value = false;
532532
}
533533
534+
// Reset the next page fields //
535+
const resetPageFields = (pageIndex: number) => {
536+
const page = computedPages.value[pageIndex + 1];
537+
538+
if (!page) {
539+
return;
540+
}
541+
542+
if (!page?.fields?.length) {
543+
return;
544+
}
545+
546+
for (const field of page.fields) {
547+
if (field.name) {
548+
$useForm.resetField(field.name, { force: true });
549+
}
550+
}
551+
};
552+
534553
// ------------------------ Check the if the page has errors //
535554
function checkForPageErrors(errors: ValidateResult['errors'], source: string, next = () => { }): void {
536555
const page = computedPages.value[currentPageIdx.value];
@@ -553,6 +572,7 @@ function checkForPageErrors(errors: ValidateResult['errors'], source: string, ne
553572
removePageError(pageIndex);
554573
555574
if (next && !lastPage.value && source !== 'submit') {
575+
resetPageFields(pageIndex);
556576
next();
557577
}
558578
}

src/plugin/components/fields/VSFCustom/VSFCustom.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const settings = inject<Ref<Settings>>('settings')!;
4747
4848
const FieldLabelComponent = toRaw(FieldLabel);
4949
const fieldValidateOn = computed(() => field.value?.validateOn ?? settings.value.validateOn);
50+
const originalValue = modelValue.value;
5051
5152
5253
const $useField = useField(
@@ -61,6 +62,13 @@ const $useField = useField(
6162
},
6263
);
6364
65+
onUnmounted(() => {
66+
if (!settings.value.keepValuesOnUnmount) {
67+
modelValue.value = originalValue;
68+
$useField.setValue(originalValue);
69+
}
70+
});
71+
6472
6573
// ------------------------- Validate On Actions //
6674
async function onActions(action: ValidateAction): Promise<void> {

0 commit comments

Comments
 (0)