From 773182f425a388e0f2c926bd0712f42e3c95ae2f Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 7 Mar 2024 17:16:17 +1100 Subject: [PATCH] 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. --- .../ModelPanel/DefaultSettings/DefaultSettingsForm.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/DefaultSettings/DefaultSettingsForm.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/DefaultSettings/DefaultSettingsForm.tsx index 8a63bdb99b..08c6ef4c5a 100644 --- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/DefaultSettings/DefaultSettingsForm.tsx +++ b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/DefaultSettings/DefaultSettingsForm.tsx @@ -43,7 +43,7 @@ export const DefaultSettingsForm = ({ const [updateModel, { isLoading }] = useUpdateModelMutation(); - const { handleSubmit, control, formState } = useForm({ + const { handleSubmit, control, formState, reset } = useForm({ 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 (