From f1f958a7aeb20b64bd779eeb90351e97f5309a0b Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Tue, 15 Aug 2023 08:52:07 -0300 Subject: [PATCH] CtrlBackspace fixed on Macbook --- src/frontend/src/utils/reactflowUtils.ts | 29 ++++++++---------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index e5d583676..9a42c5f04 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -239,27 +239,18 @@ export function handleKeyDown( inputValue: string | string[] | null, block: string ) { + console.log(e, inputValue, block); //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))) - ) { - 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))) + (typeof inputValue === "string" && + (e.metaKey === true || e.ctrlKey === true) && + e.key === "Backspace" && + (inputValue === block || + inputValue?.charAt(inputValue?.length - 1) === " " || + specialCharsRegex.test(inputValue?.charAt(inputValue?.length - 1)))) || + (navigator.userAgent.toUpperCase().includes("MAC") && + e.ctrlKey === true && + e.key === "Backspace") ) { e.preventDefault(); e.stopPropagation();