🐛 fix(parameterComponent): fix data mutation by cloning data object before updating it
🐛 fix(parameterComponent): fix data mutation by cloning data object before updating it 🐛 fix(genericModal): remove unnecessary cloning of nodeClass object 🐛 fix(genericModal): fix validation logic for PROMPT type modal 🐛 fix(reactflowUtils): remove console.log statement in handleKeyDown function
This commit is contained in:
parent
63d1e82c80
commit
144fdbd098
3 changed files with 18 additions and 18 deletions
|
|
@ -321,11 +321,16 @@ export default function ParameterComponent({
|
||||||
field_name={name}
|
field_name={name}
|
||||||
setNodeClass={(nodeClass) => {
|
setNodeClass={(nodeClass) => {
|
||||||
data.node = nodeClass;
|
data.node = nodeClass;
|
||||||
|
const clone = cloneDeep(data);
|
||||||
|
clone.node = nodeClass;
|
||||||
|
setData(clone);
|
||||||
}}
|
}}
|
||||||
nodeClass={data.node}
|
nodeClass={data.node}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
value={data.node.template[name].value ?? ""}
|
value={data.node.template[name].value ?? ""}
|
||||||
onChange={handleOnNewValue}
|
onChange={(e) => {
|
||||||
|
handleOnNewValue(e);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import { cloneDeep } from "lodash";
|
|
||||||
import { ReactNode, useContext, useEffect, useRef, useState } from "react";
|
import { ReactNode, useContext, useEffect, useRef, useState } from "react";
|
||||||
import SanitizedHTMLWrapper from "../../components/SanitizedHTMLWrapper";
|
import SanitizedHTMLWrapper from "../../components/SanitizedHTMLWrapper";
|
||||||
import ShadTooltip from "../../components/ShadTooltipComponent";
|
import ShadTooltip from "../../components/ShadTooltipComponent";
|
||||||
|
|
@ -133,21 +132,21 @@ export default function GenericModal({
|
||||||
|
|
||||||
function validatePrompt(closeModal: boolean): void {
|
function validatePrompt(closeModal: boolean): void {
|
||||||
//nodeClass is always null on tweaks
|
//nodeClass is always null on tweaks
|
||||||
if (nodeClass) {
|
|
||||||
const nodeClassCp = cloneDeep(nodeClass);
|
|
||||||
nodeClassCp["template"]["template"]["value"] = inputValue;
|
|
||||||
nodeClass = nodeClassCp;
|
|
||||||
}
|
|
||||||
postValidatePrompt(field_name, inputValue, nodeClass!)
|
postValidatePrompt(field_name, inputValue, nodeClass!)
|
||||||
.then((apiReturn) => {
|
.then((apiReturn) => {
|
||||||
if (apiReturn.data) {
|
if (apiReturn.data) {
|
||||||
|
setValue(inputValue);
|
||||||
|
apiReturn.data.frontend_node["template"]["template"]["value"] =
|
||||||
|
inputValue;
|
||||||
|
setNodeClass!(apiReturn?.data?.frontend_node);
|
||||||
|
|
||||||
let inputVariables = apiReturn.data.input_variables ?? [];
|
let inputVariables = apiReturn.data.input_variables ?? [];
|
||||||
if (inputVariables && inputVariables.length === 0) {
|
if (inputVariables && inputVariables.length === 0) {
|
||||||
setIsEdit(true);
|
setIsEdit(true);
|
||||||
setNoticeData({
|
setNoticeData({
|
||||||
title: "Your template does not have any variables.",
|
title: "Your template does not have any variables.",
|
||||||
});
|
});
|
||||||
setNodeClass!(apiReturn?.data?.frontend_node);
|
|
||||||
setModalOpen(closeModal);
|
setModalOpen(closeModal);
|
||||||
} else {
|
} else {
|
||||||
setIsEdit(false);
|
setIsEdit(false);
|
||||||
|
|
@ -157,9 +156,9 @@ export default function GenericModal({
|
||||||
if (
|
if (
|
||||||
JSON.stringify(apiReturn.data?.frontend_node) !==
|
JSON.stringify(apiReturn.data?.frontend_node) !==
|
||||||
JSON.stringify({})
|
JSON.stringify({})
|
||||||
)
|
) {
|
||||||
setModalOpen(closeModal);
|
setModalOpen(closeModal);
|
||||||
setValue(inputValue);
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setIsEdit(true);
|
setIsEdit(true);
|
||||||
|
|
@ -306,9 +305,7 @@ export default function GenericModal({
|
||||||
setModalOpen(false);
|
setModalOpen(false);
|
||||||
break;
|
break;
|
||||||
case TypeModal.PROMPT:
|
case TypeModal.PROMPT:
|
||||||
!inputValue || inputValue === ""
|
validatePrompt(false);
|
||||||
? setModalOpen(false)
|
|
||||||
: validatePrompt(false);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -200,10 +200,9 @@ export function validateNode(
|
||||||
e.targetHandle.split("|")[2] === n.id
|
e.targetHandle.split("|")[2] === n.id
|
||||||
)
|
)
|
||||||
? [
|
? [
|
||||||
`${type} is missing ${
|
`${type} is missing ${template.display_name || toNormalCase(template[t].name)
|
||||||
template.display_name || toNormalCase(template[t].name)
|
}.`,
|
||||||
}.`,
|
]
|
||||||
]
|
|
||||||
: []
|
: []
|
||||||
),
|
),
|
||||||
[] as string[]
|
[] as string[]
|
||||||
|
|
@ -239,7 +238,6 @@ export function handleKeyDown(
|
||||||
inputValue: string | string[] | null,
|
inputValue: string | string[] | null,
|
||||||
block: string
|
block: string
|
||||||
) {
|
) {
|
||||||
console.log(e, inputValue, block);
|
|
||||||
//condition to fix bug control+backspace on Windows/Linux
|
//condition to fix bug control+backspace on Windows/Linux
|
||||||
if (
|
if (
|
||||||
(typeof inputValue === "string" &&
|
(typeof inputValue === "string" &&
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue