mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
However bubble up when clicking on label container itself
This commit is contained in:
parent
9cbcfa1bbf
commit
a826895f0b
1 changed files with 8 additions and 3 deletions
|
@ -67,16 +67,21 @@ export class LabelContainer extends HTMLDivElement {
|
||||||
this.toggleSticky = this.toggleSticky.bind(this);
|
this.toggleSticky = this.toggleSticky.bind(this);
|
||||||
this.toggleStickyEvent = this.toggleStickyEvent.bind(this);
|
this.toggleStickyEvent = this.toggleStickyEvent.bind(this);
|
||||||
this.keepFocus = this.keepFocus.bind(this);
|
this.keepFocus = this.keepFocus.bind(this);
|
||||||
|
this.stopPropagation = this.stopPropagation.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
keepFocus(event: Event): void {
|
keepFocus(event: Event): void {
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stopPropagation(event: Event): void {
|
||||||
|
this.keepFocus(event);
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
connectedCallback(): void {
|
connectedCallback(): void {
|
||||||
this.addEventListener("mousedown", this.keepFocus);
|
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("click", this.toggleStickyEvent);
|
||||||
this.sticky.addEventListener("mouseenter", this.hoverIcon);
|
this.sticky.addEventListener("mouseenter", this.hoverIcon);
|
||||||
this.sticky.addEventListener("mouseleave", this.removeHoverIcon);
|
this.sticky.addEventListener("mouseleave", this.removeHoverIcon);
|
||||||
|
@ -84,7 +89,7 @@ export class LabelContainer extends HTMLDivElement {
|
||||||
|
|
||||||
disconnectedCallback(): void {
|
disconnectedCallback(): void {
|
||||||
this.removeEventListener("mousedown", this.keepFocus);
|
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("click", this.toggleStickyEvent);
|
||||||
this.sticky.removeEventListener("mouseenter", this.hoverIcon);
|
this.sticky.removeEventListener("mouseenter", this.hoverIcon);
|
||||||
this.sticky.removeEventListener("mouseleave", this.removeHoverIcon);
|
this.sticky.removeEventListener("mouseleave", this.removeHoverIcon);
|
||||||
|
|
Loading…
Reference in a new issue