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

Ember.js 3.20.4 no longer compensating for EmberArray implementation oversight in ED #7328

Closed
samcic opened this issue Sep 18, 2020 · 7 comments

Comments

@samcic
Copy link

samcic commented Sep 18, 2020

This was originally opened in emberjs/ember.js#19139, but @pzuraq asserted that it's an ED issue related to the implementation of EmberArray, which ember.js is no longer compensating for as of Ember 3.20.4, so I've reopened it here.

May be related to #7310 ,which already has a PR ready with a failing test case.

Issue copied below for reference:

🐞 Describe the Bug

If I'm tracking a model object with a hasMany list of items, I have a getter that uses those items to compute something else, and I clear those items, then the getter doesn't fire (but it does if I add items to the list).

Here's a quick video to describe it visually:

https://recordit.co/OeEey7Edrw

I've also confirmed the issue on the latest Ember.js Beta build (3.22-beta-3).

I'm aware of various other similarly-sounding reports of issues between 3.20.3 and 3.20.4 (e.g. this one on sort, and this one which seems rather similar but is apparently fixed in 3.22-beta-3). I don't believe there's an open issue tracking this particular behavior.

🔬 Minimal Reproduction

Describe steps to reproduce. If possible, please, share a link with a minimal reproduction.

  • git clone https://github.com/samcic/reactivity-bug.git
  • cd reactivity-bug
  • yarn install
  • ember serve
  • Navigate to http://localhost:4200/
  • Click the "Add" button to add some items to the collection and watch the counter increase
  • Click the "Clear" button to clear the items collection and watch the counter do nothing => BUG!
  • Click the "Add" button again to add another item, and watch the counter increase to 1 (i.e. the collection was cleared but the getter didn't react to the "cleared" state).

😕 Actual Behavior

When the collection is cleared, the getter itemsLength doesn't fire and the template doesn't update.

🤔 Expected Behavior

When the collection is cleared, the getter itemsLength should fire and the template should show the count 0.

🌍 Environment

  • Ember: 3.20.4 to current (issue doesn't exist in 3.20.3)
  • Ember-Data: ~3.21.0
  • Node.js/npm: 12.14.0
  • OS: Windows 10
  • Browser: Chrome 85
@snewcomer
Copy link
Contributor

@samcic Do you happen to have a reproduction? Want to see if #7330 covers your use case

@samcic
Copy link
Author

samcic commented Sep 20, 2020

@snewcomer So I included a detailed reproduction in this issue description above that references my repo showing the bug. Is that what you mean? If not, could you please clarify what you're after? I'd be happy to write a failing unit test if that's what you mean (although I must admit I haven't got any experience doing that on this repo yet)...

@snewcomer
Copy link
Contributor

👋 I'm not seeing the repo reference in these issues...

@samcic
Copy link
Author

samcic commented Sep 20, 2020

@snewcomer Hmmm that's interesting. I've copy/pasted it below for you:

Repro

  • git clone https://github.com/samcic/reactivity-bug.git
  • cd reactivity-bug
  • yarn install
  • ember serve
  • Navigate to http://localhost:4200/
  • Click the "Add" button to add some items to the collection and watch the counter increase
  • Click the "Clear" button to clear the items collection and watch the counter do nothing => BUG!
  • Click the "Add" button again to add another item, and watch the counter increase to 1 (i.e. the collection was cleared but the getter didn't react to the "cleared" state).

Actual Behavior
When the collection is cleared, the getter itemsLength doesn't fire and the template doesn't update.

Expected Behavior
When the collection is cleared, the getter itemsLength should fire and the template should show the count 0.

@snewcomer
Copy link
Contributor

@samcic Looks like this PR fixes your issue! Let me know if you have any comments or thoughts.

@samcic
Copy link
Author

samcic commented Sep 26, 2020

@snewcomer Yep looks good, nice work! I guess this will be closed when the PR is merged, but feel free to close it directly if you want.

@snewcomer
Copy link
Contributor

@samcic 👋 Mind trying out 3.22.0? I'll close now as you have indicated but feel free to reopen at your convenience if it still isn't working!

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