(
+ field.handleChange(e.target.value)}
+ />
+ )}
+ />
+
+
+
+
+
+ )
+ }
+
+ const { getByTestId } = render()
+ const input = getByTestId('fieldinput')
+ const changeProps = getByTestId('change-props')
+ const changePropsAgain = getByTestId('change-props-again')
+
+ await user.click(changeProps)
+ await waitFor(() => expect(input).toHaveValue('props-change'))
+
+ // checks stableRef is comparing against previously set default
+ await user.click(changePropsAgain)
+ await waitFor(() => expect(input).toHaveValue('props-change-again'))
+ })
})
diff --git a/packages/vue-form/tests/useForm.test.tsx b/packages/vue-form/tests/useForm.test.tsx
index 7d03f5896..66abd8e5a 100644
--- a/packages/vue-form/tests/useForm.test.tsx
+++ b/packages/vue-form/tests/useForm.test.tsx
@@ -476,4 +476,55 @@ describe('useForm', () => {
await waitFor(() => getByText(error))
expect(getByText(error)).toBeInTheDocument()
})
+
+ it('form should reset default value when resetting in onSubmit', async () => {
+ const Comp = defineComponent(() => {
+ const form = useForm({
+ defaultValues: {
+ name: '',
+ },
+ onSubmit: ({ value }) => {
+ expect(value).toEqual({ name: 'test' })
+
+ form.reset({ name: 'test' })
+ },
+ })
+
+ return () => (
+
+
+ {({ field }: { field: AnyFieldApi }) => (
+
+ field.handleChange((e.target as HTMLInputElement).value)
+ }
+ />
+ )}
+
+
+
+
+ )
+ })
+
+ const { getByTestId } = render()
+ const input = getByTestId('fieldinput')
+ const submit = getByTestId('submit')
+
+ await user.type(input, 'test')
+ await waitFor(() => expect(input).toHaveValue('test'))
+
+ await user.click(submit)
+
+ await waitFor(() => expect(input).toHaveValue('test'))
+ })
})