From 175229384fa3a6c55fcdd9ec06d14795aadd96d5 Mon Sep 17 00:00:00 2001 From: Romain Hamel Date: Tue, 10 Sep 2024 14:09:42 +0200 Subject: [PATCH] chore(Form): catch-up with `v2` changes (#2165) Co-authored-by: Benjamin Canac --- src/runtime/components/Form.vue | 9 +++------ src/runtime/components/FormField.vue | 5 +++-- src/runtime/components/RadioGroup.vue | 2 +- src/runtime/components/Textarea.vue | 4 ++++ src/runtime/composables/useFormField.ts | 22 +++++++++++++--------- src/runtime/types/form.ts | 1 - test/components/Form.spec.ts | 3 ++- test/components/RadioGroup.spec.ts | 8 +++++++- 8 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/runtime/components/Form.vue b/src/runtime/components/Form.vue index 9437c0e6..ee824ad7 100644 --- a/src/runtime/components/Form.vue +++ b/src/runtime/components/Form.vue @@ -157,15 +157,12 @@ async function _validate(opts: { name?: string | string[], silent?: boolean, nes } async function onSubmit(payload: Event) { - const event = payload as SubmitEvent + const event = payload as FormSubmitEvent try { await _validate({ nested: true }) - const submitEvent: FormSubmitEvent = { - ...event, - data: props.state - } - emits('submit', submitEvent) + event.data = props.state + emits('submit', event) } catch (error) { if (!(error instanceof FormValidationException)) { throw error diff --git a/src/runtime/components/FormField.vue b/src/runtime/components/FormField.vue index 30ed69f3..1d682f1c 100644 --- a/src/runtime/components/FormField.vue +++ b/src/runtime/components/FormField.vue @@ -38,7 +38,7 @@ export interface FormFieldSlots {