Open lluisgener opened 7 years ago
Well this is really strange, thanks for the report!
I can see that, after the deletion, when _itemsChanged is called, there is a problem retrieving the correct index. I think that you can't rely on the items.# index, because I think it's the internal key polymer uses in the original array and it no longer matches the correct element.
Even though, I tried to modify the index to the correct one while debugging, and still no luck.
I think you can improve the index/item detection part with the following code:
//var index = items.path.split('.')[1].substring(1);
//var item = this.items[index];
var index = items.path.split('.')[1];
var col = Polymer.Collection.get(items.base);
var item = col.getItem(index);
Please note that this doesn't fix the issue, but I think it fixes the bad index retrieval.
Also, I'm pretty sure the bug is related to the _cachedItems array. If I replace the binding in the iron-list with "items", the edit/delete bug is fixed... But obviously, filtering, and many other things get broken.
I think I have managed to fix the problem. I am not sure if it may have some side effects, or performance is degraded in any way. It seems to work, even with filtering, sorting, etc...
Also, I have added two lines to try to restore scroll position when a _resetData is invoked.
I have attached two files:
iron-data-table.html.txt --> the fixes are marked with LGE test-iron-data-table.html.txt --> test file to compare iron-data-table with iron-list and see if they go out of sync
After deleting a row, all edits done to rows after the deleted one are not refreshed properly (usually don't refreshed at all, sometimes refreshing multiple rows (on some odd tests I did), or refreshing the last row when trying to update the penultimate).
The code:
Steps to reproduce:
Click edit on first row (for example). You can see the name is updated Click delete on second row (for example). You can see the row is deleted Click edit on any row. You can see nothing happens, unless it's the first row, or the penultimate.
There is a commented iron-list to check if the issue was with the inner iron-list or the iron-data-table. You can see that iron-list doesn't have this issue.