From 4d9a9811c0ff242592297756b9d656626334a5e2 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 19 Feb 2026 13:33:34 -0600 Subject: [PATCH] don't mutate with lodash --- .../theme/fields/DetectorHardwareField.tsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/web/src/components/config-form/theme/fields/DetectorHardwareField.tsx b/web/src/components/config-form/theme/fields/DetectorHardwareField.tsx index a848da84c..871131111 100644 --- a/web/src/components/config-form/theme/fields/DetectorHardwareField.tsx +++ b/web/src/components/config-form/theme/fields/DetectorHardwareField.tsx @@ -6,7 +6,6 @@ import type { UiSchema, } from "@rjsf/utils"; import { toFieldPathId } from "@rjsf/utils"; -import { cloneDeep, set as lodashSet } from "lodash"; import { useCallback, useEffect, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { @@ -303,9 +302,9 @@ export function DetectorHardwareField(props: FieldProps) { const updateDetectors = useCallback( (nextDetectors: JsonObject, path?: FieldPathList) => { - onChange(nextDetectors as unknown, path ?? ([] as FieldPathList)); + onChange(nextDetectors as unknown, path ?? fieldPathId.path); }, - [onChange], + [fieldPathId.path, onChange], ); const getTypeLabel = useCallback( @@ -595,12 +594,10 @@ export function DetectorHardwareField(props: FieldProps) { const handleInstanceChange = ( nextValue: unknown, path: FieldPathList, - _errors?: ErrorSchema, - _id?: string, + errors?: ErrorSchema, + id?: string, ) => { - const nextDetectors = cloneDeep(detectors); - lodashSet(nextDetectors, path, nextValue); - updateDetectors(nextDetectors); + onChange(nextValue, path, errors, id); }; return ( @@ -623,17 +620,16 @@ export function DetectorHardwareField(props: FieldProps) { }, [ detectorSchemaByType, - detectors, getInstanceUiSchema, disabled, errorSchema, fieldPathId, hideError, + onChange, onBlur, onFocus, readonly, registry, - updateDetectors, ], );