Skip to content

Commit 8d5c26f

Browse files
authored
fix(Form): refine nested prop type handling and simplify logic (#5360)
1 parent fc0223a commit 8d5c26f

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/runtime/components/Form.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export type FormProps<S extends FormSchema, T extends boolean = true, N extends
5050
* If true, this form will attach to its parent Form and validate at the same time.
5151
* @defaultValue `false`
5252
*/
53-
nested?: N
53+
nested?: N & boolean
5454
5555
/**
5656
* When `true`, all form elements will be disabled on `@submit` event.
@@ -104,15 +104,12 @@ const formId = props.id ?? useId() as string
104104
105105
const bus = useEventBus<FormEvent<I>>(`form-${formId}`)
106106
107-
// The comparison with '' is needed because vue is not casting boolean correctly without
108-
// explicitly setting the prop to true (`:nested="true" works, but `nested` returns '')
109-
const isNested = props.nested?.toString() === '' || props.nested === true
110-
const parentBus = isNested && inject(
107+
const parentBus = props.nested === true && inject(
111108
formBusInjectionKey,
112109
undefined
113110
)
114111
115-
const parentState = isNested ? inject(formStateInjectionKey, undefined) : undefined
112+
const parentState = props.nested === true ? inject(formStateInjectionKey, undefined) : undefined
116113
const state = computed(() => {
117114
if (parentState?.value) {
118115
return props.name ? getAtPath(parentState.value, props.name) : parentState.value

0 commit comments

Comments
 (0)