Skip to content

Commit 1affeda

Browse files
committedAug 7, 2024
fix: fixed freezed columns index calculation
1 parent dc38184 commit 1affeda

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎src/DataTable/DataTable.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
138138
} = useColumns(columns, onColumnOrderChange, defaultSortFieldId, defaultSortAsc);
139139

140140
const freezedColumns = React.useMemo(() => {
141-
const index = tableColumns.findIndex(column => column.freeze);
142-
return tableColumns.slice(0, index + 1);
141+
// Find index of last freezed column
142+
const index = tableColumns.reduce((i, column) => {
143+
if (column.freeze) {
144+
i += 1;
145+
}
146+
return i;
147+
}, 0);
148+
return tableColumns.slice(0, index);
143149
}, [tableColumns]);
144150

145151
const [

0 commit comments

Comments
 (0)