mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-12 16:16:42 +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 }) => {
|
const subscription = watch((value, { name }) => {
|
||||||
if (name === nameField) {
|
if (name === nameField) {
|
||||||
const processedId = effectiveProcessId(value[nameField] || "");
|
const processedId = effectiveProcessId(value[nameField] || "");
|
||||||
setValue(idField, processedId as PathValue<T, Path<T>>);
|
setValue(idField, processedId as PathValue<T, Path<T>>, {
|
||||||
trigger(idField);
|
shouldValidate: false,
|
||||||
|
});
|
||||||
|
// Only trigger validation if nameField has no errors
|
||||||
|
if (!errors[nameField]) {
|
||||||
|
trigger(idField);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return () => subscription.unsubscribe();
|
return () => subscription.unsubscribe();
|
||||||
}, [watch, setValue, trigger, nameField, idField, effectiveProcessId]);
|
}, [
|
||||||
|
watch,
|
||||||
|
setValue,
|
||||||
|
trigger,
|
||||||
|
nameField,
|
||||||
|
idField,
|
||||||
|
effectiveProcessId,
|
||||||
|
errors,
|
||||||
|
]);
|
||||||
|
|
||||||
const idError = errors[idField];
|
const idError = errors[idField];
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user