Skip to content

Commit

Permalink
fix(table): avoid scrolling when updating data
Browse files Browse the repository at this point in the history
  • Loading branch information
vicgeralds committed Jun 27, 2024
1 parent 1e2c296 commit 019b570
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/table/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,12 @@ export class Table {
}

@Watch('data')
protected updateData(newData = [], oldData = []) {
if (isEqual(newData, oldData)) {
protected updateData(newData: RowData[] = [], oldData: RowData[] = []) {
const newIds = new Set(newData.map((item) => item.id ?? item));

if (oldData.every((item) => newIds.has(item.id ?? item))) {
this.tabulator.updateOrAddData(newData);

return;
}

Expand Down

0 comments on commit 019b570

Please sign in to comment.