diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index c61cadc2b..a9e279e21 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -28,6 +28,7 @@ import { ParameterComponentType } from "../../../../types/components"; import { TabsState } from "../../../../types/tabs"; import { convertObjToArray, + convertValuesToNumbers, hasDuplicateKeys, isValidConnection, } from "../../../../utils/reactflowUtils"; @@ -399,9 +400,10 @@ export default function ParameterComponent({ } duplicateKey={errorDuplicateKey} onChange={(newValue) => { - data.node!.template[name].value = newValue; - setErrorDuplicateKey(hasDuplicateKeys(newValue)); - handleOnNewValue(newValue); + const valueToNumbers = convertValuesToNumbers(newValue); + data.node!.template[name].value = valueToNumbers; + setErrorDuplicateKey(hasDuplicateKeys(valueToNumbers)); + handleOnNewValue(valueToNumbers); }} /> diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index da503befc..0e0e07155 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -317,4 +317,21 @@ export function hasDuplicateKeys(array) { } } return false; -} \ No newline at end of file +} + +export function convertValuesToNumbers(arr) { + return arr.map((obj) => { + const newObj = {}; + for (const key in obj) { + if (obj.hasOwnProperty(key)) { + let value = obj[key]; + if (/\s/g.test(value)) { + value = value.trim(); + } + newObj[key] = value === "" || isNaN(value) ? value.toString() : Number(value); + } + } + return newObj; + }); +} +