mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-11 07:45:41 +03:00
only validate id field when name field has no errors
This commit is contained in:
parent
3f2ed743eb
commit
126cc5a23e
@ -64,12 +64,25 @@ export default function NameAndIdFields<T extends FieldValues = FieldValues>({
|
||||
const subscription = watch((value, { name }) => {
|
||||
if (name === nameField) {
|
||||
const processedId = effectiveProcessId(value[nameField] || "");
|
||||
setValue(idField, processedId as PathValue<T, Path<T>>);
|
||||
trigger(idField);
|
||||
setValue(idField, processedId as PathValue<T, Path<T>>, {
|
||||
shouldValidate: false,
|
||||
});
|
||||
// Only trigger validation if nameField has no errors
|
||||
if (!errors[nameField]) {
|
||||
trigger(idField);
|
||||
}
|
||||
}
|
||||
});
|
||||
return () => subscription.unsubscribe();
|
||||
}, [watch, setValue, trigger, nameField, idField, effectiveProcessId]);
|
||||
}, [
|
||||
watch,
|
||||
setValue,
|
||||
trigger,
|
||||
nameField,
|
||||
idField,
|
||||
effectiveProcessId,
|
||||
errors,
|
||||
]);
|
||||
|
||||
const idError = errors[idField];
|
||||
useEffect(() => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user