Skip to content

Commit c623906

Browse files
committed
🐛 Fix Table fixed columns height 1px bug agaaaaaaain
close ant-design/ant-design#20495
1 parent 7a69fd9 commit c623906

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/Table.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,9 @@ class Table<ValueType> extends React.Component<TableProps<ValueType>, TableState
316316
? this.headTable.querySelectorAll('thead')
317317
: this.bodyTable.querySelectorAll('thead');
318318
const bodyRows = this.bodyTable.querySelectorAll(`.${prefixCls}-row`) || [];
319-
const fixedColumnsHeadRowsHeight = [].map.call(headRows, (row: HTMLElement) =>
320-
row.getBoundingClientRect().height ? row.getBoundingClientRect().height - 0.5 : 'auto',
319+
const fixedColumnsHeadRowsHeight = [].map.call(
320+
headRows,
321+
(row: HTMLElement) => row.getBoundingClientRect().height || 'auto',
321322
);
322323
const state = this.store.getState();
323324
const fixedColumnsBodyRowsHeight = [].reduce.call(

src/TableHeaderRow.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,16 @@ function TableHeaderRow({
3434
const HeaderCell = components.header.cell;
3535
const rowProps = onHeaderRow(row.map(cell => cell.column), index);
3636
const customStyle = rowProps ? rowProps.style : {};
37-
const style = { height, ...customStyle };
37+
const style = {
38+
// https://github.com/ant-design/ant-design/issues/20126
39+
// https://github.com/ant-design/ant-design/issues/20269
40+
// https://github.com/ant-design/ant-design/issues/20495
41+
height:
42+
row.length > 1 && index === 0 && height && height !== 'auto'
43+
? parseInt(height.toString(), 10)
44+
: height,
45+
...customStyle,
46+
};
3847

3948
return (
4049
<HeaderRow {...rowProps} style={style}>

0 commit comments

Comments
 (0)