From 3746fac7edf1b9b1300ca8f24907d88d41d631bb Mon Sep 17 00:00:00 2001 From: Justin <38869875+justinlampley@users.noreply.github.com> Date: Mon, 23 Oct 2023 12:09:56 -0400 Subject: [PATCH] Fix issue with Device Target Form where it is selecting the wrong device if multiple devices have the same name --- src/ui/components/DeviceTargetForm/index.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ui/components/DeviceTargetForm/index.tsx b/src/ui/components/DeviceTargetForm/index.tsx index 6daf1e3d0..ed74f98b3 100644 --- a/src/ui/components/DeviceTargetForm/index.tsx +++ b/src/ui/components/DeviceTargetForm/index.tsx @@ -68,7 +68,7 @@ const DeviceTargetForm: FunctionComponent = ({ .map((item) => { return { label: item.name, - value: item.name, + value: item.id, }; }) .sort((a, b) => { @@ -87,7 +87,7 @@ const DeviceTargetForm: FunctionComponent = ({ if (currentCategory !== device.category) { setCurrentCategory(device.category); } - if (currentDevice?.name !== device.name) { + if (currentDevice?.id !== device.id) { setCurrentDevice(device); } } @@ -115,9 +115,8 @@ const DeviceTargetForm: FunctionComponent = ({ if (value === null) { setCurrentDevice(null); onChange(null); - } else if (value !== currentDevice?.name) { - const device = - deviceOptions?.find((item) => item.name === value) ?? null; + } else if (value !== currentDevice?.id) { + const device = deviceOptions?.find((item) => item.id === value) ?? null; setCurrentDevice(device); const targets = sortDeviceTargets(device?.targets ?? []); onChange(targets[0] ?? null); @@ -184,7 +183,7 @@ const DeviceTargetForm: FunctionComponent = ({ title={t('DeviceTargetForm.Device')} currentValue={ deviceSelectOptions.find( - (item) => item.value === currentDevice?.name + (item) => item.value === currentDevice?.id ) ?? null } onChange={onDeviceChange}