Skip to content

Commit a4a56c4

Browse files
fix timing for updating modelValue
1 parent b8b8951 commit a4a56c4

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/plugin/VStepperForm.vue

+14-3
Original file line numberDiff line numberDiff line change
@@ -450,16 +450,27 @@ const $useForm = useForm({
450450
});
451451
452452
// ? Make sure to update the modelValue when the form values change //
453+
const internalUpdate = ref(false);
454+
let useFormValueTimer: ReturnType<typeof setTimeout>;
455+
453456
watch(() => $useForm.values, (newVal) => {
457+
internalUpdate.value = true;
454458
modelValue.value = JSON.parse(JSON.stringify(newVal));
455459
456460
callbacks();
461+
462+
clearTimeout(useFormValueTimer);
463+
useFormValueTimer = setTimeout(() => {
464+
internalUpdate.value = false;
465+
}, 0);
457466
}, { deep: true });
458467
459468
watch(modelValue, (newVal) => {
460-
Object.entries(newVal).forEach(([key, value]) => {
461-
$useForm.setFieldValue(key, value);
462-
});
469+
if (!internalUpdate.value) {
470+
Object.entries(newVal).forEach(([key, value]) => {
471+
$useForm.setFieldValue(key, value);
472+
});
473+
}
463474
}, { deep: true });
464475
465476

0 commit comments

Comments
 (0)