fix(ui): reset model edit form state with new values

Without this, the form will incorrectly compare its state to its initial default values to determine if it is dirty. Instead, it should reset its default values to the new values after successful submit.
This commit is contained in:
psychedelicious 2024-03-07 17:16:17 +11:00
parent 6386109fc5
commit 773182f425

View File

@ -43,7 +43,7 @@ export const DefaultSettingsForm = ({
const [updateModel, { isLoading }] = useUpdateModelMutation();
const { handleSubmit, control, formState } = useForm<DefaultSettingsFormData>({
const { handleSubmit, control, formState, reset } = useForm<DefaultSettingsFormData>({
defaultValues: defaultSettingsDefaults,
});
@ -76,6 +76,7 @@ export const DefaultSettingsForm = ({
})
)
);
reset(data);
})
.catch((error) => {
if (error) {
@ -90,7 +91,7 @@ export const DefaultSettingsForm = ({
}
});
},
[selectedModelKey, dispatch, updateModel, t]
[selectedModelKey, dispatch, reset, updateModel, t]
);
return (