diff --git a/interface/src/app/main/SensorsAnalogDialog.tsx b/interface/src/app/main/SensorsAnalogDialog.tsx index 4758b985b..baeb8f2b9 100644 --- a/interface/src/app/main/SensorsAnalogDialog.tsx +++ b/interface/src/app/main/SensorsAnalogDialog.tsx @@ -153,6 +153,20 @@ const SensorsAnalogDialog = ({ [creating, LL] ); + // Ensure the current GPIO is in the list when no creating + // note GPIO 99 means not set + const availableGPIOs = useMemo(() => { + const filteredList = analogGPIOList.filter((gpio) => gpio !== 99); + if ( + editItem.g !== undefined && + editItem.g !== 99 && + !filteredList.includes(editItem.g) + ) { + return [...filteredList, editItem.g].sort((a, b) => a - b); + } + return filteredList; + }, [analogGPIOList, editItem.g]); + return ( {dialogTitle} @@ -174,9 +188,8 @@ const SensorsAnalogDialog = ({ sx={{ width: '8ch' }} select onChange={updateFormValue} - disabled={editItem.s} > - {analogGPIOList?.map((gpio: number) => ( + {availableGPIOs?.map((gpio: number) => ( {gpio}