diff --git a/src/frontend/src/App.tsx b/src/frontend/src/App.tsx index 6b0180720..0088081ae 100644 --- a/src/frontend/src/App.tsx +++ b/src/frontend/src/App.tsx @@ -1,5 +1,5 @@ import _ from "lodash"; -import { useContext, useEffect, useRef, useState } from "react"; +import { useContext, useEffect, useState } from "react"; import { useLocation } from "react-router-dom"; import "reactflow/dist/style.css"; import "./App.css"; @@ -121,7 +121,6 @@ export default function App() { ); }; - return ( //need parent component with width and height
diff --git a/src/frontend/src/components/floatComponent/index.tsx b/src/frontend/src/components/floatComponent/index.tsx index 16920145f..cfa6042fa 100644 --- a/src/frontend/src/components/floatComponent/index.tsx +++ b/src/frontend/src/components/floatComponent/index.tsx @@ -1,7 +1,7 @@ import { useEffect } from "react"; import { FloatComponentType } from "../../types/components"; -import { Input } from "../ui/input"; import { handleKeyDown } from "../../utils/reactflowUtils"; +import { Input } from "../ui/input"; export default function FloatComponent({ value, @@ -45,7 +45,7 @@ export default function FloatComponent({ onChange(e.target.value); }} onKeyDown={(e) => { - handleKeyDown(e, value, '0'); + handleKeyDown(e, value, "0"); }} />
diff --git a/src/frontend/src/components/inputComponent/index.tsx b/src/frontend/src/components/inputComponent/index.tsx index bad1d68b3..4f5a5eca9 100644 --- a/src/frontend/src/components/inputComponent/index.tsx +++ b/src/frontend/src/components/inputComponent/index.tsx @@ -1,8 +1,8 @@ import { useEffect, useState } from "react"; import { InputComponentType } from "../../types/components"; +import { handleKeyDown } from "../../utils/reactflowUtils"; import { classNames } from "../../utils/utils"; import { Input } from "../ui/input"; -import { handleKeyDown } from "../../utils/reactflowUtils"; export default function InputComponent({ value, @@ -20,7 +20,6 @@ export default function InputComponent({ } }, [disabled, onChange]); - return (
{ - handleKeyDown(e, value, ''); + handleKeyDown(e, value, ""); }} /> {password && ( diff --git a/src/frontend/src/components/inputListComponent/index.tsx b/src/frontend/src/components/inputListComponent/index.tsx index 6a0ec9771..eb8ca2b5f 100644 --- a/src/frontend/src/components/inputListComponent/index.tsx +++ b/src/frontend/src/components/inputListComponent/index.tsx @@ -5,7 +5,6 @@ import _ from "lodash"; import { classNames } from "../../utils/utils"; import IconComponent from "../genericIconComponent"; import { Input } from "../ui/input"; -import { handleKeyDown } from "../../utils/reactflowUtils"; export default function InputListComponent({ value, diff --git a/src/frontend/src/components/intComponent/index.tsx b/src/frontend/src/components/intComponent/index.tsx index e2e639157..59d0ac587 100644 --- a/src/frontend/src/components/intComponent/index.tsx +++ b/src/frontend/src/components/intComponent/index.tsx @@ -1,7 +1,7 @@ import { useEffect } from "react"; import { FloatComponentType } from "../../types/components"; -import { Input } from "../ui/input"; import { handleKeyDown } from "../../utils/reactflowUtils"; +import { Input } from "../ui/input"; export default function IntComponent({ value, @@ -18,8 +18,6 @@ export default function IntComponent({ } }, [disabled, onChange]); - - return (
{ - handleKeyDown(e, inputValue, ''); + handleKeyDown(e, inputValue, ""); }} /> ) : type === TypeModal.PROMPT && !isEdit ? ( @@ -230,7 +230,7 @@ export default function GenericModal({ }} placeholder="Type message here." onKeyDown={(e) => { - handleKeyDown(e, value, ''); + handleKeyDown(e, value, ""); }} /> ) : ( diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index f26c42d83..e5d583676 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -1,10 +1,10 @@ import _ from "lodash"; import { Connection, Edge, ReactFlowInstance } from "reactflow"; +import { specialCharsRegex } from "../constants/constants"; import { APITemplateType } from "../types/api"; import { FlowType, NodeType } from "../types/flow"; import { cleanEdgesType } from "../types/utils/reactflowUtils"; import { toNormalCase } from "./utils"; -import { specialCharsRegex } from "../constants/constants"; export function cleanEdges({ flow: { edges, nodes }, @@ -234,33 +234,42 @@ export function addVersionToDuplicates(flow: FlowType, flows: FlowType[]) { return newName; } -export function handleKeyDown(e: React.KeyboardEvent, inputValue: string | string[] | null, block: string) -{ - +export function handleKeyDown( + e: React.KeyboardEvent, + inputValue: string | string[] | null, + block: string +) { //condition to fix bug control+backspace on Windows/Linux - if (typeof inputValue === "string" && e.ctrlKey === true && e.key === "Backspace" && - (inputValue === block || inputValue?.charAt(inputValue?.length - 1) === ' ' - || specialCharsRegex.test(inputValue?.charAt(inputValue?.length - 1)) - )) { + if ( + typeof inputValue === "string" && + e.ctrlKey === true && + e.key === "Backspace" && + (inputValue === block || + inputValue?.charAt(inputValue?.length - 1) === " " || + specialCharsRegex.test(inputValue?.charAt(inputValue?.length - 1))) + ) { e.preventDefault(); e.stopPropagation(); } //condition to fix bug control+backspace on Mac - if (typeof inputValue === "string" && e.metaKey === true && e.key === "Backspace" && - (inputValue === block || inputValue?.charAt(inputValue?.length - 1) === ' ' - || specialCharsRegex.test(inputValue?.charAt(inputValue?.length - 1)) - )) { + if ( + typeof inputValue === "string" && + e.metaKey === true && + e.key === "Backspace" && + (inputValue === block || + inputValue?.charAt(inputValue?.length - 1) === " " || + specialCharsRegex.test(inputValue?.charAt(inputValue?.length - 1))) + ) { e.preventDefault(); e.stopPropagation(); } - if (e.ctrlKey === true && e.key === "Backspace" && inputValue === block) { e.preventDefault(); e.stopPropagation(); } -}; +} export function getConnectedNodes( edge: Edge,