ember-changeset icon indicating copy to clipboard operation
ember-changeset copied to clipboard

Modifying a buffered property of a changeset invalidates all buffered properties

Open mwpastore opened this issue 4 years ago • 9 comments

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.

mwpastore avatar Mar 06 '20 19:03 mwpastore

@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.

snewcomer avatar Mar 06 '20 23:03 snewcomer

@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 avatar Mar 09 '20 06:03 mwpastore

@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?

mwpastore avatar May 19 '20 16:05 mwpastore

@mwpastore Can you try 3.4.0? Thank you!!

snewcomer avatar May 22 '20 18:05 snewcomer

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

mwpastore avatar May 22 '20 18:05 mwpastore

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 avatar May 22 '20 19:05 snewcomer

Hi @mwpastore! Mind trying out the latest 3.6.0?

snewcomer avatar Jun 15 '20 15:06 snewcomer

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

mwpastore avatar Jun 17 '20 20:06 mwpastore

@mwpastore 👋 👋 Any updates?

snewcomer avatar Oct 17 '20 16:10 snewcomer