Skip to content

Commit

Permalink
Fix Ctrl+X default when text editing.
Browse files Browse the repository at this point in the history
  • Loading branch information
josephbirkner committed Oct 24, 2024
1 parent cf57276 commit c2dee9f
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions erdblick_app/app/keyboard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,19 @@ export class KeyboardService {
const isInput = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable;
const key = this.getKeyCombination(event);

if (!isInput || key.includes("Ctrl")) {
if (key === 'Escape' || key === 'Esc') {
// TODO: make this work!
// if (this.dialogStack.length > 0) {
// event.preventDefault();
// const topDialog = this.dialogStack.pop();
// if (topDialog) {
// topDialog.close(new MouseEvent("mousedown"));
// }
// }
} else if (this.shortcuts.has(key)) {
event.preventDefault();
this.shortcuts.get(key)?.(event);
}
// Let non-ctrl key events or text editing shortcuts do their default things.
if (isInput && (!key.includes("Ctrl") || ["ctrl+x", "ctrl+c", "ctrl+v"].includes(key.toLowerCase()))) {
return;
}

if (this.shortcuts.has(key)) {
event.preventDefault();
this.shortcuts.get(key)?.(event);
}

// TODO: Else-if Escape was hit, close the most recent dialog
// in the stack. (JB: Can we get rid of this? Things seem
// to work fine without the dialog stack).
});
}

Expand Down

0 comments on commit c2dee9f

Please sign in to comment.