Skip to content

Commit 8e78eb1

Browse files
fix(Form): loses focus on submit (#3796)
Co-authored-by: Romain Hamel <[email protected]>
1 parent b7fc69b commit 8e78eb1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/runtime/components/Form.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ export interface FormProps<T extends object> {
3636
* @defaultValue `true`
3737
*/
3838
transform?: boolean
39+
/**
40+
* When `true`, all form elements will be disabled on `@submit` event.
41+
* This will cause any focused input elements to lose their focus state.
42+
* @defaultValue `true`
43+
*/
44+
loadingAuto?: boolean
3945
class?: any
4046
onSubmit?: ((event: FormSubmitEvent<T>) => void | Promise<void>) | (() => void | Promise<void>)
4147
}
@@ -64,7 +70,8 @@ const props = withDefaults(defineProps<FormProps<T>>(), {
6470
return ['input', 'blur', 'change'] as FormInputEvents[]
6571
},
6672
validateOnInputDelay: 300,
67-
transform: true
73+
transform: true,
74+
loadingAuto: true
6875
})
6976
7077
const emits = defineEmits<FormEmits<T>>()
@@ -213,7 +220,7 @@ const loading = ref(false)
213220
provide(formLoadingInjectionKey, readonly(loading))
214221
215222
async function onSubmitWrapper(payload: Event) {
216-
loading.value = true
223+
loading.value = props.loadingAuto && true
217224
218225
const event = payload as FormSubmitEvent<any>
219226

0 commit comments

Comments
 (0)