Convert ProductForm to react-hook-form with new RHFForm component#5310
Convert ProductForm to react-hook-form with new RHFForm component#5310
Conversation
…ield (COM-2777) Co-authored-by: nsams <50764+nsams@users.noreply.github.com>
|
@copilot fields should be in library, @comet/admin, and admin has it's own storybook (in the package source) use that. |
…n package storybook Co-authored-by: nsams <50764+nsams@users.noreply.github.com>
Done in e1e93fd. |
|
@copilot move form fields to react-hook-form/fields |
Co-authored-by: nsams <50764+nsams@users.noreply.github.com>
Done in 0670b69. Both Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: nsams <50764+nsams@users.noreply.github.com>
required prop to RHFTextField and RHFNumberField; fix endAdornment composition
Co-authored-by: nsams <50764+nsams@users.noreply.github.com>
required prop to RHFTextField and RHFNumberField; fix endAdornment compositionCo-authored-by: nsams <50764+nsams@users.noreply.github.com>
Converts
demo/admin/src/products/ProductForm.tsxfrom FinalForm to react-hook-form and introduces a newRHFFormcomponent in@comet/adminthat encapsulates the SaveBoundary wiring pattern.RHFFormcomponent (@comet/admin)New component that replaces the manual
Savable+handleSubmit+isDirtyRefboilerplate. Requires aSaveBoundaryancestor.Internally,
RHFForm:FormProviderSavableRHFthat usesuseFormContext()+useFormState()to register withSaveBoundary<form onSubmit>by delegating tosaveBoundaryApi.save()ProductForm.tsxchangesuseEffect(() => reset(data, { keepDirtyValues: true }), [data])withuseForm({ values, resetOptions: { keepDirtyValues: true } })— react-hook-form's built-in mechanism for syncing external datadoSave/isDirtyRef/hasChangeswiring;RHFFormhandles all of thatuseSaveConflictis retained;checkForConflicts()is called insideonSubmitStorybook story
Added
storybook/src/docs/form/components/ReactHookForm.stories.tsxwithEditProductFormandAddProductFormstories usingMockedProviderand the sameRHFFormpattern.📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.