mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-11 07:45:41 +03:00
ensure id field is expanded on form errors
This commit is contained in:
parent
256817d5c2
commit
3f2ed743eb
@ -41,7 +41,12 @@ export default function NameAndIdFields<T extends FieldValues = FieldValues>({
|
||||
placeholderId,
|
||||
}: NameAndIdFieldsProps<T>) {
|
||||
const { t } = useTranslation(["common"]);
|
||||
const { watch, setValue, trigger } = useFormContext<T>();
|
||||
const {
|
||||
watch,
|
||||
setValue,
|
||||
trigger,
|
||||
formState: { errors },
|
||||
} = useFormContext<T>();
|
||||
const [isIdVisible, setIsIdVisible] = useState(false);
|
||||
|
||||
const defaultProcessId = (name: string) => {
|
||||
@ -66,6 +71,13 @@ export default function NameAndIdFields<T extends FieldValues = FieldValues>({
|
||||
return () => subscription.unsubscribe();
|
||||
}, [watch, setValue, trigger, nameField, idField, effectiveProcessId]);
|
||||
|
||||
const idError = errors[idField];
|
||||
useEffect(() => {
|
||||
if (idError) {
|
||||
setIsIdVisible(true);
|
||||
}
|
||||
}, [idError]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<FormField
|
||||
|
||||
Loading…
Reference in New Issue
Block a user