From c272c2e6dbbca7780462cc3e3603c57b9e8f5468 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Thu, 13 Nov 2025 20:11:08 +0100 Subject: [PATCH] fix: form reset issue --- app/client/components/create-repository-form.tsx | 10 +++++----- app/client/components/create-volume-form.tsx | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/client/components/create-repository-form.tsx b/app/client/components/create-repository-form.tsx index fb7d8a7b..120e0f67 100644 --- a/app/client/components/create-repository-form.tsx +++ b/app/client/components/create-repository-form.tsx @@ -61,17 +61,17 @@ export const CreateRepositoryForm = ({ const { watch } = form; const watchedBackend = watch("backend"); - const watchedName = watch("name"); const { data: rcloneRemotes, isLoading: isLoadingRemotes } = useQuery({ ...listRcloneRemotesOptions(), }); useEffect(() => { - if (watchedBackend && watchedBackend in defaultValuesForType) { - form.reset({ name: watchedName, ...defaultValuesForType[watchedBackend as keyof typeof defaultValuesForType] }); - } - }, [watchedBackend, watchedName, form]); + form.reset({ + name: form.getValues().name, + ...defaultValuesForType[watchedBackend as keyof typeof defaultValuesForType], + }); + }, [watchedBackend, form]); const { capabilities } = useSystemInfo(); diff --git a/app/client/components/create-volume-form.tsx b/app/client/components/create-volume-form.tsx index 66bbe605..33040c4f 100644 --- a/app/client/components/create-volume-form.tsx +++ b/app/client/components/create-volume-form.tsx @@ -50,13 +50,15 @@ export const CreateVolumeForm = ({ onSubmit, mode = "create", initialValues, for const { watch, getValues } = form; const watchedBackend = watch("backend"); - const watchedName = watch("name"); useEffect(() => { if (mode === "create") { - form.reset({ name: watchedName, ...defaultValuesForType[watchedBackend as keyof typeof defaultValuesForType] }); + form.reset({ + name: form.getValues().name, + ...defaultValuesForType[watchedBackend as keyof typeof defaultValuesForType], + }); } - }, [watchedBackend, watchedName, form.reset, mode]); + }, [watchedBackend, form, mode]); const [testMessage, setTestMessage] = useState<{ success: boolean; message: string } | null>(null);