From df1bf1bdedb89c7253bb48fa01523d99301c0391 Mon Sep 17 00:00:00 2001 From: Charles Severance Date: Sun, 19 Jan 2025 23:07:48 -0500 Subject: [PATCH] SAK-50797 LTI fix popup WC tag timing issue --- .../sakai-lti-popup/src/SakaiLTIPopup.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/webcomponents/tool/src/main/frontend/packages/sakai-lti-popup/src/SakaiLTIPopup.js b/webcomponents/tool/src/main/frontend/packages/sakai-lti-popup/src/SakaiLTIPopup.js index 8543453a0e80..d9cc0863f487 100644 --- a/webcomponents/tool/src/main/frontend/packages/sakai-lti-popup/src/SakaiLTIPopup.js +++ b/webcomponents/tool/src/main/frontend/packages/sakai-lti-popup/src/SakaiLTIPopup.js @@ -20,6 +20,7 @@ export class SakaiLTIPopup extends SakaiElement { this.preLaunchText = null; this.postLaunchText = null; this.auto = false; + this.popped = false; this.loadTranslations("lti").then(t => { this._i18n = t; @@ -29,21 +30,22 @@ export class SakaiLTIPopup extends SakaiElement { } launchPopup() { - window.open(this.launchUrl, "_blank"); document.getElementById("sakai-lti-popup-" + this.randomId).style.display = "none"; document.getElementById("sakai-lti-popup-hidden-" + this.randomId).style.display = "block"; return false; } - shouldUpdate() { - return this.preLaunchText && this.postLaunchText && this.launchUrl; + shouldUpdate(changedProperties) { + return changedProperties.has("preLaunchText") || changedProperties.has("postLaunchText") || + changedProperties.has("launchUrl") || changedProperties.has("auto"); } - firstUpdated(changedProperties) { - changedProperties.forEach((oldValue, propName) => { - if ( propName == "auto" && this.auto ) setTimeout(this.launchPopup(), 1000); - }); + firstUpdated() { + if ( this.auto && ! this.popped ) { + this.popped = true; + setTimeout(this.launchPopup(), 1000); + } } render() {