]> BookStack Code Mirror - bookstack/blobdiff - resources/js/wysiwyg/ui/framework/helpers/dropdowns.ts
Mail: Removed custom symfony/mailer fork
[bookstack] / resources / js / wysiwyg / ui / framework / helpers / dropdowns.ts
index 751c1b3f207233134bcb8c0a3a70009d054fa8a4..890d5b325fe97b0a18f833d90eacddfefd188d2b 100644 (file)
@@ -41,11 +41,18 @@ export class DropDownManager {
 
     constructor() {
         this.onMenuMouseOver = this.onMenuMouseOver.bind(this);
+        this.onWindowClick = this.onWindowClick.bind(this);
 
-        window.addEventListener('click', (event: MouseEvent) => {
-            const target = event.target as HTMLElement;
-            this.closeAllNotContainingElement(target);
-        });
+        window.addEventListener('click', this.onWindowClick);
+    }
+
+    teardown(): void {
+        window.removeEventListener('click', this.onWindowClick);
+    }
+
+    protected onWindowClick(event: MouseEvent): void {
+        const target = event.target as HTMLElement;
+        this.closeAllNotContainingElement(target);
     }
 
     protected closeAllNotContainingElement(element: HTMLElement): void {