From 1c2095cf8e81bd12435b0a5bf2e4c21986b6be14 Mon Sep 17 00:00:00 2001 From: rhenck <richard.henck@iqb.hu-berlin.de> Date: Fri, 15 Oct 2021 14:18:06 +0200 Subject: [PATCH] [editor] Improve delete key logic This now uses "closest" to check parent nodes. This still does not work properly since some elements can not be clicked and the event returns the body element. This might be fixed if a way to make those elements clickable is found. --- .../unit-view/page-view/canvas/canvas-element-overlay.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/editor/src/app/components/unit-view/page-view/canvas/canvas-element-overlay.ts b/projects/editor/src/app/components/unit-view/page-view/canvas/canvas-element-overlay.ts index 22b672d2d..6e0214c9f 100644 --- a/projects/editor/src/app/components/unit-view/page-view/canvas/canvas-element-overlay.ts +++ b/projects/editor/src/app/components/unit-view/page-view/canvas/canvas-element-overlay.ts @@ -54,9 +54,9 @@ export abstract class CanvasElementOverlay implements OnInit, OnDestroy { @HostListener('window:keydown', ['$event']) handleKeyDown(event: KeyboardEvent): void { - if ((event.target as Element).parentElement && - (event.target as Element).parentElement!.parentElement && - (event.target as Element).parentElement!.parentElement!.className.indexOf('aspect-inserted-element') > -1 && + if ((event.target as Element).tagName !== 'INPUT' && (event.target as Element).tagName !== 'TEXTAREA' && + ((event.target as Element).className.indexOf('aspect-inserted-element') > -1 || + (event.target as Element).closest('.aspect-inserted-element')) && event.key === 'Delete') { this.selectionService.selectedElements .pipe(take(1)) -- GitLab