From 6a1f1857e44ac18c91ef083eff8ca9bd8af7356d Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Tue, 30 Jul 2024 18:34:09 -0300 Subject: [PATCH] fix: text input jumps to the end of the text after writing one letter (#3090) Fixed not being able to write in the middle of the component --- .../parameterRenderComponent/index.tsx | 210 +++++++++--------- 1 file changed, 108 insertions(+), 102 deletions(-) diff --git a/src/frontend/src/components/parameterRenderComponent/index.tsx b/src/frontend/src/components/parameterRenderComponent/index.tsx index 1a1679fb2..f4252f187 100644 --- a/src/frontend/src/components/parameterRenderComponent/index.tsx +++ b/src/frontend/src/components/parameterRenderComponent/index.tsx @@ -1,6 +1,7 @@ import { TEXT_FIELD_TYPES } from "@/CustomNodes/GenericNode/components/parameterComponent/constants"; import { handleOnNewValueType } from "@/CustomNodes/hooks/use-handle-new-value"; import { APIClassType, InputFieldType } from "@/types/api"; +import { useMemo } from "react"; import CodeAreaComponent from "../codeAreaComponent"; import DictComponent from "../dictComponent"; import FloatComponent from "../floatComponent"; @@ -44,107 +45,112 @@ export function ParameterRenderComponent({ templateData.name ).toLowerCase(); - return ( - - {TEXT_FIELD_TYPES.includes(templateData.type ?? "") ? ( - - ) : templateData.type === "NestedDict" ? ( - - ) : templateData.type === "dict" ? ( - - ) : templateData.type === "bool" ? ( - - ) : templateData.type === "float" ? ( - - ) : templateData.type === "int" ? ( - - ) : templateData.type === "file" ? ( - - ) : templateData.type === "prompt" ? ( - - ) : templateData.type === "code" ? ( - - ) : templateData.type === "Any" ? ( - <>- - ) : ( - String(templateValue) - )} - + return useMemo( + () => ( + + {TEXT_FIELD_TYPES.includes(templateData.type ?? "") ? ( + + ) : templateData.type === "NestedDict" ? ( + + ) : templateData.type === "dict" ? ( + + ) : templateData.type === "bool" ? ( + + ) : templateData.type === "float" ? ( + + ) : templateData.type === "int" ? ( + + ) : templateData.type === "file" ? ( + + ) : templateData.type === "prompt" ? ( + + ) : templateData.type === "code" ? ( + + ) : templateData.type === "Any" ? ( + <>- + ) : ( + String(templateValue) + )} + + ), + [templateData, disabled, nodeId, editNode, nodeClass, name, templateValue], ); }