-
Notifications
You must be signed in to change notification settings - Fork 76
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
key=
not working as expected
#188
Comments
The issue you're having is caused by the fact that this computed property does not have any dependent keys: https://github.com/amk221/-ember-vertical-collection-issue/blob/master/app/components/person-tags.js#L7 Vertical collection recycles components, which means that you have 8 table rows that are never being fully destroyed or recreated. The computed property won't update unless you change something it's dependent on, |
Yes, I thought that would be mentioned. Thanks for the I mention this because, in the past, I've had this same issue with a standard |
Roughly speaking, In both cases it allows the diff algorithm to determine when an item in the previous state of the list matches an item in the new state of the list. In the case of In the case of Fundamentally, recycling components in Ember or Glimmer today has fundamental difficulties due to the non FP nature of some older Ember features and patterns. Generally speaking, setting state in I don’t think that @amk221 wants to use Changing to the following would resolve the issue tags: computed('person.tags.length', function() {
return this.get('person.tags').map(t => t.name);
}) If for some reason this to be very expensive and something that required more stability, moving this calculation higher up the chain would be better e.g. Person {
tags = [];
tagNames = computed('tags.length', function() { return this.tags.map(t => t.name); };
} |
Thanks for the write up. My use of Using So I think my point that |
When specifying
key="@index"
, rows do not seem to be stabilising as expected (perhaps I am expecting the wrong thing?)Please see this screencast and demo repo for an example:
https://github.com/amk221/-ember-vertical-collection-issue#ember-vertical-collection-issue
Each person has some tags. (Their ids match for the simplicity of the test case).
However, upon scrolling notice how the tag id no longer matches the person for that row.
The text was updated successfully, but these errors were encountered: