Skip to content

Commit

Permalink
fix: wrong first or last column when pinned. (#701)
Browse files Browse the repository at this point in the history
Co-authored-by: 章勇 <zhangyong@zhangyong.com>
  • Loading branch information
YongThePsibor and 章勇 committed Oct 4, 2023
1 parent 1da14f2 commit 31078bf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/material-react-table/src/column.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,21 @@ export const getIsFirstColumn = <TData extends Record<string, any>>(
column: MRT_Column<TData>,
table: MRT_TableInstance<TData>,
) => {
return table.getVisibleLeafColumns()[0].id === column.id;
const leftColumns = table.getLeftVisibleLeafColumns();
return leftColumns.length
? leftColumns[0].id === column.id
: table.getVisibleLeafColumns()[0].id === column.id;
};

export const getIsLastColumn = <TData extends Record<string, any>>(
column: MRT_Column<TData>,
table: MRT_TableInstance<TData>,
) => {
const rightColumns = table.getRightVisibleLeafColumns();
const columns = table.getVisibleLeafColumns();
return columns[columns.length - 1].id === column.id;
return rightColumns.length
? rightColumns[rightColumns.length - 1].id === column.id
: columns[columns.length - 1].id === column.id;
};

export const getIsLastLeftPinnedColumn = <TData extends Record<string, any>>(
Expand Down

0 comments on commit 31078bf

Please sign in to comment.