Field not deleted when using update
RWOverdijk opened this issue · comments
Are you submitting a bug report or a feature request?
Bug report.
What is the current behavior?
When using FormApi.change('someField', { someNested: 'object' })
after deleting an entry from the object final-form sets it to null
instead of reming it.
const { values } = useFormState<VenueForm>();
const form = useForm<VenueForm>();
/* ... */
const removeRegion = (key: string) => {
const newRegions = { ...values.regions };
delete newRegions[key];
// Will still submit the `regions` with the old key entry, with value null.
form.change('regions', newRegions);
};
What is the expected behavior?
Delete the field. Don't set it to null.
I even tried writing my own mutator:
const overwrite = (
[name, value]: any[],
state: any,
{ changeValue }: any
) => changeValue(state, name, (): any[] => value);
But it just refuses to delete the key.
Cool.
@RWOverdijk Did you ever find a fix / workaround for this?
Yeah. I built my own library.
Sorry I can't be of more help.