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

Modifying a buffered property of a changeset invalidates all buffered properties #437

Open
mwpastore opened this issue Mar 6, 2020 · 9 comments

Comments

@mwpastore
Copy link

mwpastore commented Mar 6, 2020

Got a weird one here. Not sure if it's intentional but I suspect not. Essentially, changing any buffered property of an ember-changeset causes the observers of all buffered properties to fire (i.e. the whole buffer is invalidated). If you have an underlying object with lots of properties and associated DOM, this can get real messy, real fast. I put together a basic repro that shows (clearly, I hope) the differences in behavior between a POJO and an ember-changeset.

Version

3.0.6

Test Case

https://github.com/mwpastore/-ember-changeset-notify

Steps to reproduce

Modify any buffered property of a changeset.

Expected Behavior

Only observers of the modified property should fire.

Actual Behavior

Observers of all properties fire.

@snewcomer
Copy link
Collaborator

@mwpastore Is this potentially due to the #let block emitting a new value. For example, if I invert the problem - change useChangeset = true, toggle Use changeset?, both Did Update checkboxes are now checked.

Lmk if I am missing the goal of your repro though.

@mwpastore
Copy link
Author

mwpastore commented Mar 9, 2020

@snewcomer Yes, when you switch between a POJO and a changeset, it invalidates both properties. But that's not what I'm trying to show with my repro. The difference in behavior is most easily seen when both "Did Update?" checkboxes are un-checked—i.e. by manually un-checking them one at a time; or by clicking "(clear)" to un-check them both at the same time.

Maybe a "script" would help. You can run through these steps, and feel free to play with the starting conditions. It does not matter whether "Use changeset?" is initially true or false.

When "Use changeset?" is un-checked:

  1. Click "(clear)" to un-check both "Did Update?" checkboxes
  2. Toggle the "Value" checkbox under Foo
  3. Note that the "Did Update?" checkbox under Foo is now checked, but the checkbox under Bar remains unchecked, because the value of Bar did not change

When "Use changeset?" is checked:

  1. Click "(clear)" to un-check both "Did Update?" checkboxes
  2. Toggle the "Value" checkbox under Foo
  3. Note that the "Did Update?" checkbox under Foo is now checked, and the checkbox under Bar is also now checked, even though the value of Bar did not change

@mwpastore
Copy link
Author

@snewcomer This still appears to be an issue with Ember 3.18.1 and ember-changeset 3.3.8. Has my most recent comment helped explain the problem I'm seeing, or is it still unclear?

@snewcomer
Copy link
Collaborator

@mwpastore Can you try 3.4.0? Thank you!!

@mwpastore
Copy link
Author

@snewcomer No change. Do you have an inkling of what/where the problem is?

@snewcomer
Copy link
Collaborator

Not anymore. We have overhauled the get access on a changeset so it should work completely with any level of nested properties. I think what would be best to get to the core of the issue is one simple failing test in this repo or validated-changeset.

@snewcomer
Copy link
Collaborator

Hi @mwpastore! Mind trying out the latest 3.6.0?

@mwpastore
Copy link
Author

@snewcomer No change. I hope to have some time to work on that failing test next week. Cheers.

@snewcomer
Copy link
Collaborator

@mwpastore 👋 👋 Any updates?

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

No branches or pull requests

2 participants