fix: form reset issue
This commit is contained in:
parent
25b5d98a3e
commit
c272c2e6db
2 changed files with 10 additions and 8 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue