Skip to content

Commit

Permalink
Merge pull request #569 from justinlampley/FixDeviceTargetFormSelecti…
Browse files Browse the repository at this point in the history
…onIssue

Fix issue with Device Target Form
  • Loading branch information
justinlampley authored Oct 29, 2023
2 parents 4e5f2e8 + 3746fac commit 96dc298
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/ui/components/DeviceTargetForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const DeviceTargetForm: FunctionComponent<FirmwareVersionCardProps> = ({
.map((item) => {
return {
label: item.name,
value: item.name,
value: item.id,
};
})
.sort((a, b) => {
Expand All @@ -87,7 +87,7 @@ const DeviceTargetForm: FunctionComponent<FirmwareVersionCardProps> = ({
if (currentCategory !== device.category) {
setCurrentCategory(device.category);
}
if (currentDevice?.name !== device.name) {
if (currentDevice?.id !== device.id) {
setCurrentDevice(device);
}
}
Expand Down Expand Up @@ -115,9 +115,8 @@ const DeviceTargetForm: FunctionComponent<FirmwareVersionCardProps> = ({
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);
Expand Down Expand Up @@ -184,7 +183,7 @@ const DeviceTargetForm: FunctionComponent<FirmwareVersionCardProps> = ({
title={t('DeviceTargetForm.Device')}
currentValue={
deviceSelectOptions.find(
(item) => item.value === currentDevice?.name
(item) => item.value === currentDevice?.id
) ?? null
}
onChange={onDeviceChange}
Expand Down

0 comments on commit 96dc298

Please sign in to comment.