From 29829bb7fe029564f093766ceb2643e44f168bf6 Mon Sep 17 00:00:00 2001 From: JerryVincent Date: Wed, 25 Mar 2026 12:33:31 +0100 Subject: [PATCH] Fixes the issue with deleting multiple sensors --- app/routes/device.$deviceId.edit.sensors.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/routes/device.$deviceId.edit.sensors.tsx b/app/routes/device.$deviceId.edit.sensors.tsx index 87e17915..29b91647 100644 --- a/app/routes/device.$deviceId.edit.sensors.tsx +++ b/app/routes/device.$deviceId.edit.sensors.tsx @@ -111,13 +111,9 @@ export default function EditBoxSensors() { setToastOpen(true) // window.location.reload(); //* reset sensor data elements - for (let index = 0; index < sensorsData.length; index++) { + for (let index = sensorsData.length - 1; index >= 0; index--) { const sensor = sensorsData[index] - if (sensor.new == true && sensor.notValidInput == true) { - sensorsData.splice(index, 1) - } else if (sensor.deleted) { - sensorsData.splice(index, 1) - } else if (sensor.new == true && sensor.notValidInput == true) { + if (sensor.deleted || (sensor.new == true && sensor.notValidInput == true)) { sensorsData.splice(index, 1) } else if (sensor.editing == true) { delete sensor.editing