From ab0f936025d75802ee768a5a562f25a62e392e63 Mon Sep 17 00:00:00 2001 From: Dmitry Artemov Date: Wed, 9 Oct 2024 15:05:45 +0200 Subject: [PATCH] fix(BaseTable): fix virtual rows positioning when reordering or sorting rows (#71) --- src/components/BaseTable/BaseTable.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/BaseTable/BaseTable.tsx b/src/components/BaseTable/BaseTable.tsx index 3f5e1e7..88c7e4c 100644 --- a/src/components/BaseTable/BaseTable.tsx +++ b/src/components/BaseTable/BaseTable.tsx @@ -196,6 +196,9 @@ export const BaseTable = React.forwardRef( ? rows[virtualItemOrRow.index] : (virtualItemOrRow as Row); + const virtualItem = rowVirtualizer ? (virtualItemOrRow as VirtualItem) : undefined; + const key = virtualItem?.key ?? row.id; + const rowProps: BaseRowProps = { cellClassName, className: rowClassName, @@ -212,7 +215,7 @@ 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() @@ -220,10 +223,10 @@ export const BaseTable = React.forwardRef( }; if (draggableContext) { - return ; + return ; } - return ; + return ; }); };