From e2f0f2069e8c192d7ec61d8ad13bef27ceee6ef6 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Fri, 4 Aug 2023 16:04:15 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(reactflowUtils.ts):=20preven?= =?UTF-8?q?t=20default=20behavior=20and=20stop=20propagation=20of=20keyboa?= =?UTF-8?q?rd=20event=20when=20pressing=20Ctrl=20+=20Backspace=20on=20inpu?= =?UTF-8?q?t=20value=20that=20matches=20block=20or=20ends=20with=20a=20spa?= =?UTF-8?q?ce=20character=20to=20improve=20user=20experience?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/utils/reactflowUtils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 5aff862b5..0b3449b45 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -235,7 +235,12 @@ export function addVersionToDuplicates(flow: FlowType, flows: FlowType[]) { export function handleKeyDown(e: React.KeyboardEvent, inputValue: string | string[] | null, block: string) { - if (e.ctrlKey && inputValue === block && e.key === "Backspace") { + if (typeof inputValue === "string" && e.ctrlKey && e.key === "Backspace" && (inputValue === block || inputValue?.charAt(inputValue?.length - 1) === ' ')) { + e.preventDefault(); + e.stopPropagation(); + } + + if (e.ctrlKey && e.key === "Backspace" && inputValue === block) { e.preventDefault(); e.stopPropagation(); }