Skip to content
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

Fix shouldUpdate in entity-mixin-lit #482

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

svanherk
Copy link
Collaborator

I'm a bit worried about this change, but in theory it should only be a good thing. Basically, anything using both the EntityMixinLit and core's LocalizeDynamicMixin isn't actually waiting until the langterms are loaded before rendering. This is probably only actually noticeable in the OSLO case, where langterms take a while to return.

I think the fix below is the correct way to do this - EntityMixinLit gets the chance to say "no, don't update, we don't have an href/token" but will then default to other mixin's requirements if its good to go with the update.

Thoughts?

@svanherk svanherk requested a review from a team May 19, 2022 21:51
@github-actions
Copy link

PR Checklist:

Did you use a semver keyword in a commit message?

  • Yes I used one in at least one of my commits
  • No but I will use a semver keyword in the commit message when I merge and squash

Did you paste the Rally US URL in the description?

  • Yes
  • No as there's no corresponding Rally US

Copy link
Collaborator

@dlockhart dlockhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the right change -- it may break some tests in other repos potentially since rendering may happen a bit later.

@@ -35,7 +35,7 @@ export const EntityMixinLit = superclass => class extends superclass {
this.href && this.token) {
this._getEntity();
}
return this.href && this.token;
return this.href && this.token ? super.shouldUpdate(changedProperties) : false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually... localize-mixin.js had to do a bunch of extra work to accomplish something similar, so I'm worried something is getting lost here. Like it's remembering the list of updated properties when it returns false so that later when it can call super.shouldUpdate(changedProperties) it can include all the ones that it skipped.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting, I can look into that

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible that it's overkill... you could probably just remember if super.shouldUpdate(changedProperties) would have ever returned true (when you're returning false because href/token aren't defined yet) and then if so, return that value.

Copy link
Collaborator Author

@svanherk svanherk May 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah interesting, I think it's overkill for the use cases I know about because the localizeMixin doesn't actually use the changedProperties. But there could be another mixin after it that does... could this be turned into a controller mixins could use? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants