From ffb9fa706ab7f8ecd5130c895f9a6bc2a2d9bfd2 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 16 May 2023 15:00:43 -0600 Subject: [PATCH] Filemanager: Fix new file button stopped working after being readonly Moved option render inside render() since we have it, simplifys things a lot --- .../Et2DropdownButton/Et2DropdownButton.ts | 37 +++++-------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/api/js/etemplate/Et2DropdownButton/Et2DropdownButton.ts b/api/js/etemplate/Et2DropdownButton/Et2DropdownButton.ts index eacf1837c9..d50ce96694 100644 --- a/api/js/etemplate/Et2DropdownButton/Et2DropdownButton.ts +++ b/api/js/etemplate/Et2DropdownButton/Et2DropdownButton.ts @@ -91,49 +91,32 @@ export class Et2DropdownButton extends Et2widgetWithSelectMixin(Et2Button) // Rebind click to just the main button, not the whole thing this.removeEventListener("click", this._handleClick); - - // Need to wait until update is done and these exist - this.updateComplete.then(() => - { - if(this.buttonNode) - { - this.buttonNode.addEventListener("click", this._handleClick); - } - if(this.dropdownNode) - { - this.dropdownNode.addEventListener('sl-select', this._handleSelect); - } - }); } - disconnectedCallback() + protected _renderOptions() { - super.disconnectedCallback(); - if(this.buttonNode) - { - this.buttonNode.removeEventListener("click", this._handleClick); - } - if(this.dropdownNode) - { - this.dropdownNode.removeEventListener('sl-select', this._handleSelect); - } + // We have our own render, so we can handle it internally } - render() + render() : TemplateResult { if(this.readonly) { - return ''; + return html``; } return html` - + ${this.label} - + + ${(this.select_options || []).map((option : SelectOption) => this._optionTemplate(option))}