Skip to content

Commit 1d013c0

Browse files
add unmount
1 parent 8803f33 commit 1d013c0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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)