Skip to content

Commit

Permalink
Fix table issues
Browse files Browse the repository at this point in the history
  • Loading branch information
maksis committed Jan 17, 2025
1 parent 7713e66 commit 2a229d7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/components/table/RowDataLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ class RowDataLoader {
// Remove rows outside the range
// Leave the current range in case all old items can be reused
// (avoids flickering because there is no need to re-render)
for (let i = 0; i < this._data.length; i++) {
if (!items[i]) {
delete this._data[i];
this._data = produce(this._data, (draft) => {
for (let i = 0; i < draft.length; i++) {
if (!items[i]) {
draft.splice(i, 1);
}
}
}
});

// Update rows
const updatedCount = items.reduce(this.updateItem.bind(this), 0);
Expand Down Expand Up @@ -140,7 +142,7 @@ class RowDataLoader {
console.error('Failed to load data', error);
for (let i = rowBase; i < endRow; i++) {
if (this._pendingRequest[i]) {
delete this._pendingRequest[i];
this.removePendingRequests(rowIndex);
}
}
});
Expand All @@ -155,7 +157,9 @@ class RowDataLoader {
for (let i = 0; i < rows.length; i++) {
const rowIndex = start + i;
if (!isEqual(this._data[rowIndex], rows[i])) {
this._data[rowIndex] = rows[i];
this._data = produce(this._data, (draft) => {
draft[rowIndex] = rows[i];
});

if (this._pendingRequest[rowIndex]) {
this._pendingRequest[rowIndex].forEach((f) => f(rows[i]));
Expand All @@ -164,7 +168,7 @@ class RowDataLoader {
console.log('onRowsReceived, row data equals', rowIndex);
}

delete this._pendingRequest[rowIndex];
this.removePendingRequests(rowIndex);
}
}
}
Expand Down

0 comments on commit 2a229d7

Please sign in to comment.