Skip to content

Commit 90457e8

Browse files
authored
fix: expandIconColumnIndex=-1 not working (#501)
close ant-design/ant-design#24129 close ant-design/ant-design#25386
1 parent b3ca90c commit 90457e8

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/hooks/useColumns.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@ function useColumns<RecordType>(
175175

176176
// Insert expand column in the target position
177177
const cloneColumns = baseColumns.slice();
178-
cloneColumns.splice(expandColIndex, 0, expandColumn);
179-
178+
if (expandColIndex >= 0) {
179+
cloneColumns.splice(expandColIndex, 0, expandColumn);
180+
}
180181
return cloneColumns;
181182
}
182183
return baseColumns;

tests/ExpandRow.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,19 @@ describe('Table.Expand', () => {
148148
).toBeTruthy();
149149
});
150150

151+
// https://github.com/ant-design/ant-design/issues/24129
152+
it('should not render expand icon column when expandIconColumnIndex is negative', () => {
153+
const wrapper = mount(
154+
createTable({
155+
expandable: {
156+
expandedRowRender,
157+
expandIconColumnIndex: -1,
158+
},
159+
}),
160+
);
161+
expect(wrapper.find('.rc-table-row-expand-icon-cell').length).toBe(0);
162+
});
163+
151164
it('renders a custom icon', () => {
152165
function CustomExpandIcon(props) {
153166
return (

0 commit comments

Comments
 (0)