Skip to content

Commit

Permalink
fix(BaseTable): fix virtual rows positioning when reordering or sorti…
Browse files Browse the repository at this point in the history
…ng rows (#71)
  • Loading branch information
beliarh authored Oct 9, 2024
1 parent 7b95f62 commit ab0f936
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/BaseTable/BaseTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ export const BaseTable = React.forwardRef(
? rows[virtualItemOrRow.index]
: (virtualItemOrRow as Row<TData>);

const virtualItem = rowVirtualizer ? (virtualItemOrRow as VirtualItem) : undefined;
const key = virtualItem?.key ?? row.id;

const rowProps: BaseRowProps<TData, TScrollElement> = {
cellClassName,
className: rowClassName,
Expand All @@ -212,18 +215,18 @@ export const BaseTable = React.forwardRef(
row,
rowVirtualizer,
table,
virtualItem: rowVirtualizer ? (virtualItemOrRow as VirtualItem) : undefined,
virtualItem,
'aria-rowindex': headerRowCount + ariaRowIndexMap[row.id],
'aria-selected': table.options.enableRowSelection
? row.getIsSelected()
: undefined,
};

if (draggableContext) {
return <BaseDraggableRow key={row.id} {...rowProps} />;
return <BaseDraggableRow key={key} {...rowProps} />;
}

return <BaseRow key={row.id} {...rowProps} />;
return <BaseRow key={key} {...rowProps} />;
});
};

Expand Down

0 comments on commit ab0f936

Please sign in to comment.