-
Notifications
You must be signed in to change notification settings - Fork 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
nested dom-repeat with sort attribute shows duplicate entries when adding new items. #1744
Comments
I fixed this in your last jsBin also: Original: go: function () {
for (var i=0; i<DATA.length; i++) {
var items = [];
var cat = {'num': DATA[i].num, items: items};
this.push('categories', cat);
for (var j=0; j<DATA[i].items.length; j++) {
// `i` here is only ever 0 or 1, so you're always pushing new items
// into categories[0].items or categories[1].items
this.push('categories.' + i + '.items', DATA[i].items[j]);
}
}
} In the inner loop, Fixed: go: function () {
for (var i=0; i<DATA.length; i++) {
var items = [];
var cat = {'num': DATA[i].num, items: items};
this.push('categories', cat);
for (var j=0; j<DATA[i].items.length; j++) {
// push onto the MOST RECENTLY ADDED category's items
this.push('categories.' + (this.categories.length-1) + '.items', DATA[i].items[j]);
}
}
} This works as expected: |
@kevinpschaaf this does NOT resolve the issue. if you look at your 'working as expected' version, you'll still see a duplicate entry at the end of each category. THAT is the issue I'm reporting. yes, clicking the button twice does have unexpected results, but that is not relevant. don't click it twice, the bug is present after 1 click. it's caused by pushing onto a nested array, and is still evident in your version. please re-open this ticket. |
Got it-- sorry that was obscured by the other issue. |
Confirmed the problem, will land a fix for this soon. Thanks guys! |
Thanks for the quick turn around, I am both the guys. :D |
lol, I hadn't noticed the similarity in user names... :) |
Issue will be resolved by #1795 Confirmed it fixes the reported issue here: |
When pushing new items into a nested array rendered by a dom-repeat with a sort attribute, duplicate items are rendered:
http://jsbin.com/fazazujamu/2/edit
(Click 'go' once, you should see items 11 and 21 duplicated in the output)
from my testing, this requires the array to be nested inside another array which is rendered with dom-repeat, and it requires the items to be added one by one, AFTER the parent item is already rendered, and must be added using this.push.
The text was updated successfully, but these errors were encountered: