-
-
Notifications
You must be signed in to change notification settings - Fork 955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SAK-50797 LTI fix popup WC tag timing issue #13211
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ export class SakaiLTIPopup extends SakaiElement { | |
this.preLaunchText = null; | ||
this.postLaunchText = null; | ||
this.auto = false; | ||
this.popped = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to set this to false. It is initially undefined which is already falsy |
||
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"); | ||
Comment on lines
+40
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should not need to do any of this because these properties are already reactive. All you are doing here is repeating lit's internal logic when any one of these four reactive properties is changed. |
||
} | ||
|
||
firstUpdated(changedProperties) { | ||
changedProperties.forEach((oldValue, propName) => { | ||
if ( propName == "auto" && this.auto ) setTimeout(this.launchPopup(), 1000); | ||
}); | ||
firstUpdated() { | ||
if ( this.auto && ! this.popped ) { | ||
this.popped = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure that if you make this reactive and just use this.popped in your template, you wont need this timeout at all. Also, you don't need the randomid if you use this.querySelector because it's scoped for you already. |
||
setTimeout(this.launchPopup(), 1000); | ||
} | ||
} | ||
|
||
render() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way you are testing for these being null in the i18n promise sets up a race condition. The setting of attributes happens after the constructor, but that setting may happen before the i18n promise fulfils. So, a user of the tag may think they are overriding the i18n default, but they maybe won't.