@@ -138,16 +138,28 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
138
138
defaultSortColumn,
139
139
} = useColumns ( columns , onColumnOrderChange , defaultSortFieldId , defaultSortAsc ) ;
140
140
141
+ // Find index of last freezed column
142
+ const index = React . useMemo (
143
+ ( ) =>
144
+ tableColumns . reduce ( ( i , column ) => {
145
+ if ( column . freeze ) {
146
+ i += 1 ;
147
+ }
148
+ return i ;
149
+ } , 0 ) ,
150
+ [ tableColumns ] ,
151
+ ) ;
152
+
153
+ const tableColumnsBasedOnTable = React . useMemo ( ( ) => {
154
+ if ( ! isInnerTable ) {
155
+ return tableColumns ;
156
+ }
157
+ return tableColumns . slice ( 0 , index ) ;
158
+ } , [ index , isInnerTable , tableColumns ] ) ;
159
+
141
160
const freezedColumns = React . useMemo ( ( ) => {
142
- // Find index of last freezed column
143
- const index = tableColumns . reduce ( ( i , column ) => {
144
- if ( column . freeze ) {
145
- i += 1 ;
146
- }
147
- return i ;
148
- } , 0 ) ;
149
161
return tableColumns . slice ( 0 , index ) ;
150
- } , [ tableColumns ] ) ;
162
+ } , [ index , tableColumns ] ) ;
151
163
152
164
const [
153
165
{
@@ -486,7 +498,7 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
486
498
</ >
487
499
) }
488
500
489
- { tableColumns . map ( column => (
501
+ { tableColumnsBasedOnTable . map ( column => (
490
502
< Column
491
503
key = { column . id }
492
504
column = { column }
@@ -534,7 +546,7 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
534
546
key = { id }
535
547
keyField = { keyField }
536
548
data-row-id = { id }
537
- columns = { tableColumns }
549
+ columns = { tableColumnsBasedOnTable }
538
550
row = { row }
539
551
rowCount = { sortedData . length }
540
552
rowIndex = { i }
@@ -585,7 +597,7 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
585
597
</ Wrapper >
586
598
</ ResponsiveWrapper >
587
599
588
- { ! isInnerTable && freezedColumns . length > 0 && (
600
+ { freezedColumns . length > 0 && (
589
601
< div
590
602
style = { {
591
603
position : 'absolute' ,
@@ -610,7 +622,7 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
610
622
</ >
611
623
) }
612
624
613
- { freezedColumns . slice ( 0 , 3 ) . map ( column => (
625
+ { freezedColumns . map ( column => (
614
626
< Column
615
627
key = { column . id }
616
628
column = { column }
0 commit comments