-
-
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
[3.13] Regression in computed property computation #18417
Comments
Why does this happen!?! This seems completely opposite of how the system is supposed to work (to my knowledge). |
Do you mean that it wasn’t supposed to work before too? How would you do something similar?
|
Yes, I am surprised this ever mutated the parent properties value (to the point where I would consider the fact that it did a bug itself). In addition, it seems to me like it should never have recomputed at all (since the value is not consumed).
From the demo repo it is very hard to tell what you actually want to do here. Can you explain in prose what the goal is (aka if you had to write a "user story" for this in your app, what would it say)? |
@rwjblue - thanks for the support.
|
Because nothing uses or sets the value of
Sure, I agree but nothing actually uses the computed property at all in the component. This is effectively an observer (you want to mutate upwards when the parts value changes), if you swap to use an observer (and have the observer |
OK, I almost agree that the observed behavior on 3.13 is correct, but:
|
Just to throw my info on this thread, i think i encountered this same regression in a different way. I think i have a problem attaching two-way binding to a computed property with the I have a component that has a two-way bound property. This component displays input boxes based on the users preferred latitude format (degrees minutes seconds or degrees decimal minutes or .... ). Internally this component takes that When a user types into one of those boxes the property value is set to the backer unit and this then propagates to the other computed properties in the component this is then propagated up the chain to the This is the chain:
So this is where the problem lies. Step 7 does not happen in 3.13. |
I think I may be experiencing the same problem, but expressing itself a different way. I have a computed property like this: value: computed({
get() {
return null;
},
set(value) {
// Do some side effect
return value;
}
}); This is bound to an input {{input value=value}} This works fine on Ember 3.12. On Ember 3.13 (and 3.14, and 3.15) the getter is re-computed each time, rather than using the cached value from the setter, which was the previous behavior. The resulting UX is that no matter how much you type into the input field, I recognize that this is an anti-pattern and that this code should adhere to DDAU, but this is old code that has not been updated yet. While I can refactor this to use DDAU, the reality is that this pattern is all over our codebase and the previous behavior should not have broken. |
Can you confirm that this is still an issue in 3.16 @alexlafroscia? Lot's of fixes have landed for tracked properties since the last release. If it is still an issue, we definitely should (and will) fix it and land it in 3.16, since that is the LTS. |
Yes; the issue that I am seeing on Ember 3.13-3.15 is also an issue on 3.16. Just to make sure I'm not going crazy, I went back to 3.12 and made sure to verify that that version does not have this problem (and it does not). To clarify, my understanding is that a computed property with a setter will use the return value of the setter from that point on and not re-evaluate the getter. To my understanding, that's how Ember versions up to and including 3.12 have worked. |
@alexlafroscia I'm unable to reproduce this in Ember 3.15 or 3.16: https://glitch.com/edit/#!/coffee-plywood-1ks15ajvx4?path=app/templates/application.hbs:4:0 Can you provide a reproduction, via Glitch or other code samples? |
Very odd... I'll have to keep digging into my app to see what the difference here is. Also -- TIL you can use Ember in Glitch. Neat! |
Reproduction on Glitch here: https://glitch.com/~cherry-bovid-ie855acxrz On Ember 3.12, updating On Ember 3.15, Removing the computed property resolves the issue. |
I've got a github repo that reproduces what I think is the major issue here: https://github.com/richgt/ember-computed-issue. If you change the Ember Version to 3.12, the "String" updates as you change the "A" and "B" inputs. In 3.13+, it does not. |
I've been talking with @rwjblue about this. Here's a PR that adds a test to the Ember Codebase documenting the failure: #19028. Per Robert, he's located the cause, working on a solution. in 3.12, this is what happens:
|
@rwjblue, @Kilowhisky, @alexlafroscia, @pzuraq, @richgt - I think this has since been fixed. At least in 3.25.1 the original repo that I've given works fine again. Can you all confirm that your use-cases have been fixed also so we can close the issue? @rwjblue - you mentioned that this should not happen - is that still your opinion? Because in 3.25.1 it again works as I expect it and as you expect it not to. 😄 |
Here is a reproduction repo
The last commit updates Ember to 3.13. When typing in the input, nothing happens.
The previous commit uses 3.12 and there, when typing in the checkbox, in the console a number of things happen - the computed property's
get
is called and the value is also propagated to the "parent" component/controller.This is a bug/regression.
The text was updated successfully, but these errors were encountered: