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
This commit is contained in:
Lucas Oliveira 2024-07-30 18:34:09 -03:00 • committed by GitHub
commit 6a1f1857e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,7 @@
import { TEXT_FIELD_TYPES } from "@/CustomNodes/GenericNode/components/parameterComponent/constants"; import { TEXT_FIELD_TYPES } from "@/CustomNodes/GenericNode/components/parameterComponent/constants";
import { handleOnNewValueType } from "@/CustomNodes/hooks/use-handle-new-value"; import { handleOnNewValueType } from "@/CustomNodes/hooks/use-handle-new-value";
import { APIClassType, InputFieldType } from "@/types/api"; import { APIClassType, InputFieldType } from "@/types/api";
import { useMemo } from "react";
import CodeAreaComponent from "../codeAreaComponent"; import CodeAreaComponent from "../codeAreaComponent";
import DictComponent from "../dictComponent"; import DictComponent from "../dictComponent";
import FloatComponent from "../floatComponent"; import FloatComponent from "../floatComponent";
@ -44,7 +45,8 @@ export function ParameterRenderComponent({
templateData.name templateData.name
).toLowerCase(); ).toLowerCase();
return ( return useMemo(
() => (
<RefreshParameterComponent <RefreshParameterComponent
templateData={templateData} templateData={templateData}
disabled={disabled} disabled={disabled}
@ -68,7 +70,9 @@ export function ParameterRenderComponent({
<DictComponent <DictComponent
disabled={disabled} disabled={disabled}
editNode={editNode} editNode={editNode}
value={(templateValue || "").toString() === "{}" ? {} : templateValue} value={
(templateValue || "").toString() === "{}" ? {} : templateValue
}
onChange={onChange} onChange={onChange}
id={`dict_${id}`} id={`dict_${id}`}
/> />
@ -146,5 +150,7 @@ export function ParameterRenderComponent({
String(templateValue) String(templateValue)
)} )}
</RefreshParameterComponent> </RefreshParameterComponent>
),
[templateData, disabled, nodeId, editNode, nodeClass, name, templateValue],
); );
} }