From a29a3a8f7bb7de48f7be8c8ebaa5a3db06ad2310 Mon Sep 17 00:00:00 2001 From: Sidharth-Singh10 Date: Mon, 23 Dec 2024 16:56:40 +0530 Subject: [PATCH] Fix: delete empty text layer on right click --- frontend/src/io-managers/input.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frontend/src/io-managers/input.ts b/frontend/src/io-managers/input.ts index 484f4f735e..2f10b4bd5c 100644 --- a/frontend/src/io-managers/input.ts +++ b/frontend/src/io-managers/input.ts @@ -170,6 +170,18 @@ export function createInputManager(editor: Editor, dialog: DialogState, portfoli e.preventDefault(); e.stopPropagation(); } + // Handle right-click outside text input but within viewport + if (!inTextInput && !inContextMenu && isTargetingCanvas && e.button === 2) { + if (textToolInteractiveInputElement) { + // Send empty text to trigger the same behavior as ESC key + const text = textInputCleanup(textToolInteractiveInputElement.innerText); + if (text === "") { + editor.handle.onKeyDown("Escape", 0, false); + } else { + editor.handle.onChangeText(text); + } + } + } if (!inTextInput && !inContextMenu) { if (textToolInteractiveInputElement) editor.handle.onChangeText(textInputCleanup(textToolInteractiveInputElement.innerText));