From a826895f0b226265c6b62256e75d87b6bf69b519 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 7 Sep 2021 15:02:59 +0200 Subject: [PATCH] However bubble up when clicking on label container itself --- ts/editor/label-container.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ts/editor/label-container.ts b/ts/editor/label-container.ts index 49071a678..1491dcb6c 100644 --- a/ts/editor/label-container.ts +++ b/ts/editor/label-container.ts @@ -67,16 +67,21 @@ export class LabelContainer extends HTMLDivElement { this.toggleSticky = this.toggleSticky.bind(this); this.toggleStickyEvent = this.toggleStickyEvent.bind(this); this.keepFocus = this.keepFocus.bind(this); + this.stopPropagation = this.stopPropagation.bind(this); } keepFocus(event: Event): void { - event.stopPropagation(); event.preventDefault(); } + stopPropagation(event: Event): void { + this.keepFocus(event); + event.stopPropagation(); + } + connectedCallback(): void { this.addEventListener("mousedown", this.keepFocus); - this.sticky.addEventListener("mousedown", this.keepFocus); + this.sticky.addEventListener("mousedown", this.stopPropagation); this.sticky.addEventListener("click", this.toggleStickyEvent); this.sticky.addEventListener("mouseenter", this.hoverIcon); this.sticky.addEventListener("mouseleave", this.removeHoverIcon); @@ -84,7 +89,7 @@ export class LabelContainer extends HTMLDivElement { disconnectedCallback(): void { this.removeEventListener("mousedown", this.keepFocus); - this.sticky.removeEventListener("mousedown", this.keepFocus); + this.sticky.removeEventListener("mousedown", this.stopPropagation); this.sticky.removeEventListener("click", this.toggleStickyEvent); this.sticky.removeEventListener("mouseenter", this.hoverIcon); this.sticky.removeEventListener("mouseleave", this.removeHoverIcon);