From b7160e6eaf3a772c6465607e61a3fba3bd328b38 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 11 Sep 2024 15:02:37 -0600 Subject: [PATCH] Et2TreeDropdown: stop constantly listening for document clicks, only listen when open --- api/js/etemplate/Et2Tree/Et2TreeDropdown.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts b/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts index ce87cbbb19..c83c8e8d49 100644 --- a/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts +++ b/api/js/etemplate/Et2Tree/Et2TreeDropdown.ts @@ -133,14 +133,11 @@ export class Et2TreeDropdown extends SearchMixin & Et2InputWidg connectedCallback() { super.connectedCallback(); - - document.addEventListener("click", this.handleDocumentClick); } disconnectedCallback() { super.disconnectedCallback(); - document.removeEventListener("click", this.handleDocumentClick); } updated(changedProperties : PropertyValues) @@ -242,6 +239,7 @@ export class Et2TreeDropdown extends SearchMixin & Et2InputWidg return undefined; } + document.addEventListener("click", this.handleDocumentClick); this.open = true; this.requestUpdate("open", false) return this.updateComplete @@ -255,6 +253,8 @@ export class Et2TreeDropdown extends SearchMixin & Et2InputWidg return undefined; } + document.removeEventListener("click", this.handleDocumentClick); + this.open = false; this._popup.active = false; this._searchNode.value = ""; @@ -510,10 +510,12 @@ export class Et2TreeDropdown extends SearchMixin & Et2InputWidg { this._popup.active = false; this._searchNode.value = ""; + document.removeEventListener("click", this.handleDocumentClick); } else { this._popup.active = true; + document.addEventListener("click", this.handleDocumentClick); } this.open = this._popup.active; this.treeOrSearch = "tree";