Skip to content

Commit

Permalink
Fix: delete empty text layer on right click
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidharth-Singh10 committed Dec 23, 2024
1 parent 60901c0 commit b7fffa7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions frontend/src/io-managers/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit b7fffa7

Please sign in to comment.