From 8e78eb15c85beef1c814206c4a192d4eb00a7e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20M=C3=A1ximiliano=2C=20Lo=20Giudice?= Date: Mon, 14 Apr 2025 06:02:27 -0300 Subject: [PATCH] fix(Form): loses focus on submit (#3796) Co-authored-by: Romain Hamel --- src/runtime/components/Form.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/runtime/components/Form.vue b/src/runtime/components/Form.vue index 57de7b5b..ffb6ada2 100644 --- a/src/runtime/components/Form.vue +++ b/src/runtime/components/Form.vue @@ -36,6 +36,12 @@ export interface FormProps { * @defaultValue `true` */ transform?: boolean + /** + * When `true`, all form elements will be disabled on `@submit` event. + * This will cause any focused input elements to lose their focus state. + * @defaultValue `true` + */ + loadingAuto?: boolean class?: any onSubmit?: ((event: FormSubmitEvent) => void | Promise) | (() => void | Promise) } @@ -64,7 +70,8 @@ const props = withDefaults(defineProps>(), { return ['input', 'blur', 'change'] as FormInputEvents[] }, validateOnInputDelay: 300, - transform: true + transform: true, + loadingAuto: true }) const emits = defineEmits>() @@ -213,7 +220,7 @@ const loading = ref(false) provide(formLoadingInjectionKey, readonly(loading)) async function onSubmitWrapper(payload: Event) { - loading.value = true + loading.value = props.loadingAuto && true const event = payload as FormSubmitEvent