mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-13 00:26:42 +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,
|
placeholderId,
|
||||||
}: NameAndIdFieldsProps<T>) {
|
}: NameAndIdFieldsProps<T>) {
|
||||||
const { t } = useTranslation(["common"]);
|
const { t } = useTranslation(["common"]);
|
||||||
const { watch, setValue, trigger } = useFormContext<T>();
|
const {
|
||||||
|
watch,
|
||||||
|
setValue,
|
||||||
|
trigger,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext<T>();
|
||||||
const [isIdVisible, setIsIdVisible] = useState(false);
|
const [isIdVisible, setIsIdVisible] = useState(false);
|
||||||
|
|
||||||
const defaultProcessId = (name: string) => {
|
const defaultProcessId = (name: string) => {
|
||||||
@ -66,6 +71,13 @@ export default function NameAndIdFields<T extends FieldValues = FieldValues>({
|
|||||||
return () => subscription.unsubscribe();
|
return () => subscription.unsubscribe();
|
||||||
}, [watch, setValue, trigger, nameField, idField, effectiveProcessId]);
|
}, [watch, setValue, trigger, nameField, idField, effectiveProcessId]);
|
||||||
|
|
||||||
|
const idError = errors[idField];
|
||||||
|
useEffect(() => {
|
||||||
|
if (idError) {
|
||||||
|
setIsIdVisible(true);
|
||||||
|
}
|
||||||
|
}, [idError]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<FormField
|
<FormField
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user