diff --git a/src/hooks/useColumns/index.tsx b/src/hooks/useColumns/index.tsx index 99490db32..fcc007ab0 100644 --- a/src/hooks/useColumns/index.tsx +++ b/src/hooks/useColumns/index.tsx @@ -176,9 +176,13 @@ function useColumns( // >>> Insert expand column if not exist if (!cloneColumns.includes(EXPAND_COLUMN)) { const expandColIndex = expandIconColumnIndex || 0; - if (expandColIndex >= 0) { + console.log(expandColIndex); + if (expandColIndex >= 0 && (expandColIndex || fixed === 'left' || !fixed)) { cloneColumns.splice(expandColIndex, 0, EXPAND_COLUMN); } + if (fixed === 'right') { + cloneColumns.splice(baseColumns.length, 0, EXPAND_COLUMN); + } } // >>> Deduplicate additional expand column @@ -197,10 +201,8 @@ function useColumns( const prevColumn = baseColumns[expandColumnIndex]; let fixedColumn: FixedType | null; - if ((fixed === 'left' || fixed) && !expandIconColumnIndex) { - fixedColumn = 'left'; - } else if ((fixed === 'right' || fixed) && expandIconColumnIndex === baseColumns.length) { - fixedColumn = 'right'; + if (fixed) { + fixedColumn = fixed; } else { fixedColumn = prevColumn ? prevColumn.fixed : null; } diff --git a/tests/__snapshots__/ExpandRow.spec.jsx.snap b/tests/__snapshots__/ExpandRow.spec.jsx.snap index 72dfbbe21..f10c8e2b3 100644 --- a/tests/__snapshots__/ExpandRow.spec.jsx.snap +++ b/tests/__snapshots__/ExpandRow.spec.jsx.snap @@ -138,7 +138,7 @@ LoadedCheerio { exports[`Table.Expand > does not crash if scroll is not set 1`] = ` LoadedCheerio { "0":
- - - + - -
- -
-   -
-
- - @@ -260,14 +235,6 @@ LoadedCheerio { class="rc-table-row rc-table-row-level-0" data-row-key="1" > - - - @@ -323,7 +290,7 @@ LoadedCheerio { exports[`Table.Expand > does not crash if scroll is not set 2`] = ` LoadedCheerio { "0":
- - - + - -
- -
-   -
-
- - @@ -445,14 +387,6 @@ LoadedCheerio { class="rc-table-row rc-table-row-level-0" data-row-key="1" > - - - @@ -1183,7 +1117,7 @@ LoadedCheerio { exports[`Table.Expand > work in expandable fix 1`] = ` LoadedCheerio { "0":
- - - + - - @@ -1481,8 +1382,8 @@ LoadedCheerio { F
- -
-   -
-
- - @@ -1305,14 +1214,6 @@ LoadedCheerio { class="rc-table-row rc-table-row-level-0" data-row-key="1" > - - - @@ -1368,7 +1269,7 @@ LoadedCheerio { exports[`Table.Expand > work in expandable fix 2`] = ` LoadedCheerio { "0":