@@ -39,6 +39,12 @@ export interface FormProps<T extends object> {
39
39
* @defaultValue `true`
40
40
*/
41
41
transform? : boolean
42
+ /**
43
+ * When `true`, all form elements will be disabled on `@submit` event.
44
+ * This will cause any focused input elements to lose their focus state.
45
+ * @defaultValue `true`
46
+ */
47
+ loadingAuto? : boolean
42
48
class? : any
43
49
onSubmit? : ((event : FormSubmitEvent <T >) => void | Promise <void >) | (() => void | Promise <void >)
44
50
}
@@ -65,7 +71,8 @@ const props = withDefaults(defineProps<FormProps<T>>(), {
65
71
return [' input' , ' blur' , ' change' ] as FormInputEvents []
66
72
},
67
73
validateOnInputDelay: 300 ,
68
- transform: true
74
+ transform: true ,
75
+ loadingAuto: true
69
76
})
70
77
71
78
const emits = defineEmits <FormEmits <T >>()
@@ -211,7 +218,6 @@ provide(formLoadingInjectionKey, readonly(loading))
211
218
212
219
async function onSubmitWrapper(payload : Event ) {
213
220
const event = payload as FormSubmitEvent <any >
214
- const activeElement = document .activeElement as HTMLElement
215
221
216
222
loading .value = true
217
223
@@ -232,11 +238,11 @@ async function onSubmitWrapper(payload: Event) {
232
238
emits (' error' , errorEvent )
233
239
} finally {
234
240
loading .value = false
235
- setTimeout (() => activeElement ?.focus (), 0 )
236
241
}
237
242
}
238
243
239
- const disabled = computed (() => props .disabled || loading .value )
244
+ const isLoading = computed (() => loading .value && props .loadingAuto )
245
+ const disabled = computed (() => props .disabled || isLoading .value )
240
246
241
247
provide (formOptionsInjectionKey , computed (() => ({
242
248
disabled: disabled .value ,
0 commit comments