diff --git a/src/frontend/src/constants/constants.ts b/src/frontend/src/constants/constants.ts index 0ff77cf45..68730bbf9 100644 --- a/src/frontend/src/constants/constants.ts +++ b/src/frontend/src/constants/constants.ts @@ -29,6 +29,7 @@ export const INVALID_CHARACTERS = [ */ export const regexHighlight = /\{([^}]+)\}/g; +export const specialCharsRegex = /[!@#$%^&*()\-_=+[\]{}|;:'",.<>/?\\]/; export const programmingLanguages: languageMap = { javascript: ".js", diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 0b3449b45..ae7de3f0d 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -4,6 +4,7 @@ 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 }, @@ -235,7 +236,11 @@ export function addVersionToDuplicates(flow: FlowType, flows: FlowType[]) { export function handleKeyDown(e: React.KeyboardEvent, inputValue: string | string[] | null, block: string) { - if (typeof inputValue === "string" && e.ctrlKey && e.key === "Backspace" && (inputValue === block || inputValue?.charAt(inputValue?.length - 1) === ' ')) { + + if (typeof inputValue === "string" && e.ctrlKey && e.key === "Backspace" && + (inputValue === block || inputValue?.charAt(inputValue?.length - 1) === ' ' + || specialCharsRegex.test(inputValue?.charAt(inputValue?.length - 1)) + )) { e.preventDefault(); e.stopPropagation(); }