-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Template does not get updated with tracked (computed) getter #18988
Comments
Changing the getter to just return this.confirmName !== this.eventName; solves the issue but I still think it is a bug. Don't know why the tracked property was recomputed but UI didn't change though |
For some reason, on previous conditions, property was recomputed, but UI wasn't updated. that only happened in production builds as well. Changing the condition slightly as a workaround worked. Upstream Issue: emberjs/ember.js#18988
Was |
Just to confirm, what is "the computed property" referring to here? Do you mean the |
|
I'd like to mention again that in both cases, the function is being re-evaluated on changing of |
Is In your example, you use a ternary statement which only returns the result if This is logically sound because the only update that could cause changes here is if If |
eventName doesn't change. It's static Also, eventName is a prop passed from parent component |
Hi @pzuraq , I don't see "short-circuiting" mentioned in the Ember docs. Is it a bug that will be fixed or is it something that developers need to avoid? |
@lhz516 short circuiting is not mentioned directly, it's the outcome of applying the rules of autotracking. Autotracking is based on usage, so if you don't use something, then it will not be tracked. If you never end the |
@pzuraq What if accessing some nested properties in the getter? get val() {
return this.a && this.a.b && this.a.b.c; // `c` is tracked
} Is the only way to give both get val() {
return this.a.b.c;
} |
@lhz516 if |
@pzuraq Could you advise how one can debug short-circuiting? I have a very nested data structure to mimic a document (an email to be specific), and I'm trying to get rid of Structure is deeply nested: So say one component changes the style's
but the component responsible for applying styles doesn't see that change. Not in getters in JS-file nor in the template 🤷♂️ Thank you for any tip that has the potential to move me in right direction 🙏 |
@tniezurawski I've run into something similar and I think the choices are:
I don't know of a deepTracked that tracks everything automatically (similarly to what's used in ember-redux). Since that doesn't exist, we've been using POJOs for our data store and then use |
I have a pretty weird bug which only happens on production build.
This is the component
This is the template:
As you can see, the delete button should get enabled only when confirmName == eventName, which it does on debug build, in production build, it doesn't. I used ember devtools to check if tracked property
isNameDifferent
is being recomputed and it is, it changes tofalse
when I type event name, but the button is not enabled. Now comes the weirdest part, when I added a console log statement in the getter:It starts working correctly, I tried multiple times and it only starts working in production build when I add this console.log statement. I thought this was a bug in autotracking but the computed property is recalculated anyway even when it doesn't update the template/HTML, so I have no idea why it is not working.
This started happening right after I migrated to tracked properties fossasia/open-event-frontend@2801505
Upstream Issue: fossasia/open-event-frontend#4383
Ember Versions:
The text was updated successfully, but these errors were encountered: