-
Notifications
You must be signed in to change notification settings - Fork 809
feat(FormField): add required
field support across form components
#4534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v3
Are you sure you want to change the base?
Conversation
required
field support across form components
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rdjanuar! Could you add a test for the required inheritance here? https://github.com/nuxt/ui/blob/v3/test/components/FormField.spec.ts#L97
test/components/FormField.spec.ts
Outdated
async function renderFormField(options: { | ||
props: Partial<FormFieldProps> | ||
inputComponent: typeof inputComponents[number] | ||
}) { | ||
return await mountSuspended(UFormField, { | ||
props: options.props, | ||
return await mountSuspended(UForm, { | ||
slots: { | ||
default: { | ||
// @ts-expect-error - Object literal may only specify known properties, and setup does not exist in type | ||
setup: () => ({ inputComponent: options.inputComponent }), | ||
setup: () => ({ | ||
formFieldProps: options.props, | ||
inputComponent: options.inputComponent | ||
}), | ||
components: { | ||
UFormField, | ||
USelectMenu, | ||
UForm, | ||
...inputComponents | ||
}, | ||
template: ` | ||
<component :is="inputComponent" /> | ||
<UFormField v-bind="formFieldProps"> | ||
<component :is="inputComponent" :model-value="'0'" /> | ||
</UFormField> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should refactor renderFormField to fit with required
test because on reka-ui, there`s certain condition to show element that has required attr like select or input
docs/app/components/content/examples/input-number/InputNumberFormFieldExample.vue
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rdjanuar :)
@rdjanuar Would you mind fixing the conflicts? π¬ |
![]() i get this error while updating snapshot, any idea how to fix it ? @benjamincanac |
π Linked issue
Resolves #4529, maybe #3882
β Type of change
π Description
π Checklist