From 30ddeb79b04ec19e6a38f0f258bb0aeae2201f6c Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 28 Feb 2022 13:45:47 -0700 Subject: [PATCH] Add missing change listener --- api/js/etemplate/Et2Date/Et2Date.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/api/js/etemplate/Et2Date/Et2Date.ts b/api/js/etemplate/Et2Date/Et2Date.ts index e1dc771c98..d9a3fb30dc 100644 --- a/api/js/etemplate/Et2Date/Et2Date.ts +++ b/api/js/etemplate/Et2Date/Et2Date.ts @@ -297,6 +297,19 @@ export class Et2Date extends Et2InputWidget(FormControlMixin(ValidateMixin(LitFl super(); } + + connectedCallback() + { + super.connectedCallback(); + this._onChange = this._onChange.bind(this); + } + + disconnectedCallback() + { + super.disconnectedCallback(); + this._inputNode.removeEventListener('change', this._onChange); + } + /** * Override parent to skip call to CDN * @returns {Promise} @@ -308,6 +321,10 @@ export class Et2Date extends Et2InputWidget(FormControlMixin(ValidateMixin(LitFl // await loadLocale(this.locale); } this.initializeComponent(); + + // This has to go in init() rather than connectedCallback() because flatpickr creates its nodes in + // initializeComponent() so this._inputNode is not available before this + this._inputNode.addEventListener('change', this._onChange); } /**