From 0ad3cf9832bf4ea75189aac08cd84715acc5b708 Mon Sep 17 00:00:00 2001 From: ralf Date: Wed, 27 Jul 2022 12:33:37 +0200 Subject: [PATCH] fix not working onchange with Shoelace components: need to bind sl-change instead of change adding change handler to invoker mixing to enable/disable invoker when value changes --- api/js/etemplate/Et2InputWidget/Et2InputWidget.ts | 4 ++-- api/js/etemplate/Et2Url/Et2InvokerMixin.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts b/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts index 8099fda642..7fe5a43fc8 100644 --- a/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts +++ b/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts @@ -148,14 +148,14 @@ const Et2InputWidgetMixin = >(superclass : T) this.node = this.getInputNode(); this.updateComplete.then(() => { - this.addEventListener("change", this._oldChange); + this.addEventListener(typeof (this).handleChange === 'function' ? 'sl-change' : 'change', this._oldChange); }); } disconnectedCallback() { super.disconnectedCallback(); - this.removeEventListener("change", this._oldChange); + this.removeEventListener(typeof (this).handleChange === 'function' ? 'sl-change' : 'change', this._oldChange); } /** diff --git a/api/js/etemplate/Et2Url/Et2InvokerMixin.ts b/api/js/etemplate/Et2Url/Et2InvokerMixin.ts index e4fee61d2c..811e76346a 100644 --- a/api/js/etemplate/Et2Url/Et2InvokerMixin.ts +++ b/api/js/etemplate/Et2Url/Et2InvokerMixin.ts @@ -179,6 +179,19 @@ export const Et2InvokerMixin = dedupeMixin(>(s } } + /** + * Reimplemented to enable/disable invoker on content change + * + * @param _ev + * @returns + */ + _oldChange(_ev: Event): boolean + { + this._toggleInvokerDisabled(); + + return super._oldChange(_ev); + } + /** @param {import('@lion/core').PropertyValues } changedProperties */ firstUpdated(changedProperties) {