From 4522cd383e9f461864e3f6c70992e9c7b59c7a52 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Mon, 14 Aug 2023 16:28:52 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(reactflowUtils.ts):=20fix=20?= =?UTF-8?q?bug=20with=20control+backspace=20key=20combination=20on=20Windo?= =?UTF-8?q?ws/Linux=20and=20Mac?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/utils/reactflowUtils.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 6f18520c4..f26c42d83 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -236,9 +236,9 @@ export function addVersionToDuplicates(flow: FlowType, flows: FlowType[]) { export function handleKeyDown(e: React.KeyboardEvent, inputValue: string | string[] | null, block: string) { - console.log("check key: ", e); - if (typeof inputValue === "string" && e.ctrlKey && e.key === "Backspace" && + //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)) )) { @@ -246,7 +246,17 @@ export function handleKeyDown(e: React.KeyboardEvent, inputVal e.stopPropagation(); } - if (e.ctrlKey && e.key === "Backspace" && inputValue === block) { + //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)) + )) { + e.preventDefault(); + e.stopPropagation(); + } + + + if (e.ctrlKey === true && e.key === "Backspace" && inputValue === block) { e.preventDefault(); e.stopPropagation(); }