diff --git a/package.json b/package.json index 7ee495b..343cf3c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tp/tp-popup", - "version": "1.0.4", + "version": "1.0.5", "description": "", "main": "tp-popup.js", "scripts": { diff --git a/tp-popup.js b/tp-popup.js index 3ed55fa..9deffc5 100644 --- a/tp-popup.js +++ b/tp-popup.js @@ -117,6 +117,13 @@ class TpPopup extends EventHelpers(Position(DomQuery(LitElement))) { this.listen(this, 'click', '_onClick'); } + updated(changes) { + // Fire event only if isOpen wasn't undefined before. Otherwise an event is fired at the first render. + if (changes.has('isOpen') && changes.get('isOpen') !== undefined) { + this.dispatchEvent(new CustomEvent('is-open-changed', { detail: this.isOpen, bubbles: true, composed: true })); + } + } + disconnectedCallback() { super.disconnectedCallback(); this._cleanupEvents();