Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions assets/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,20 @@
}
}

th&-measure-cell {
padding-top: 0;
padding-bottom: 0;
border-top: 0;
border-bottom: 0;
}

&-measure-cell-content {
height: 0;
overflow: hidden;
visibility: hidden;
pointer-events: none;
}

&-content {
.tableBorder();
border-radius: 5px 0 0 0;
Expand Down
19 changes: 10 additions & 9 deletions src/Body/MeasureCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ export interface MeasureCellProps {
columnKey: React.Key;
onColumnResize: (key: React.Key, width: number) => void;
column?: ColumnType<any>;
prefixCls: string;
}

export default function MeasureCell({ columnKey, onColumnResize, column }: MeasureCellProps) {
export default function MeasureCell({
columnKey,
onColumnResize,
column,
prefixCls,
}: MeasureCellProps) {
const cellRef = React.useRef<HTMLTableCellElement>();

useLayoutEffect(() => {
Expand All @@ -20,14 +26,9 @@ export default function MeasureCell({ columnKey, onColumnResize, column }: Measu

return (
<ResizeObserver data={columnKey}>
<td
ref={cellRef}
style={{ paddingTop: 0, paddingBottom: 0, borderTop: 0, borderBottom: 0, height: 0 }}
>
<div style={{ height: 0, overflow: 'hidden', fontWeight: 'bold' }}>
{column?.title || '\xa0'}
</div>
</td>
<th ref={cellRef} className={`${prefixCls}-measure-cell`}>
<div className={`${prefixCls}-measure-cell-content`}>{column?.title || '\xa0'}</div>
</th>
</ResizeObserver>
);
}
3 changes: 2 additions & 1 deletion src/Body/MeasureRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function MeasureRow({
const { measureRowRender } = useContext(TableContext, ['measureRowRender']);

const measureRow = (
<tr aria-hidden="true" className={`${prefixCls}-measure-row`} style={{ height: 0 }} ref={ref}>
<tr aria-hidden="true" className={`${prefixCls}-measure-row`} ref={ref} tabIndex={-1}>
<ResizeObserver.Collection
onBatchResize={infoList => {
if (isVisible(ref.current)) {
Expand All @@ -37,6 +37,7 @@ export default function MeasureRow({
const column = columns.find(col => col.key === columnKey);
return (
<MeasureCell
prefixCls={prefixCls}
key={columnKey}
columnKey={columnKey}
onColumnResize={onColumnResize}
Expand Down
4 changes: 2 additions & 2 deletions tests/FixedColumn.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ describe('Table.FixedColumn', () => {
it('not break measure count', async () => {
const wrapper = mount(<Table columns={columns.slice(0, 5)} data={data} scroll={{ x: 1000 }} />);
await safeAct(wrapper);
expect(wrapper.find('.rc-table-measure-row td')).toHaveLength(5);
expect(wrapper.find('.rc-table-measure-row th')).toHaveLength(5);

wrapper.setProps({ columns: columns.slice(0, 4) });
wrapper.update();
expect(wrapper.find('.rc-table-measure-row td')).toHaveLength(4);
expect(wrapper.find('.rc-table-measure-row th')).toHaveLength(4);
});

it('when all columns fixed left,cell should has classname rc-table-cell-fix-left-all', async () => {
Expand Down
170 changes: 85 additions & 85 deletions tests/__snapshots__/ExpandRow.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -188,44 +188,44 @@ LoadedCheerio {
<tr
aria-hidden="true"
class="rc-table-measure-row"
style="height: 0px;"
tabindex="-1"
>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>

</div>
</td>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
</th>
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>
Name
</div>
</td>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
</th>
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>
Age
</div>
</td>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
</th>
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>
Gender
</div>
</td>
</th>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
Expand Down Expand Up @@ -373,44 +373,44 @@ LoadedCheerio {
<tr
aria-hidden="true"
class="rc-table-measure-row"
style="height: 0px;"
tabindex="-1"
>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>

</div>
</td>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
</th>
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>
Name
</div>
</td>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
</th>
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>
Age
</div>
</td>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
</th>
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>
Gender
</div>
</td>
</th>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
Expand Down Expand Up @@ -676,44 +676,44 @@ LoadedCheerio {
<tr
aria-hidden="true"
class="rc-table-measure-row"
style="height: 0px;"
tabindex="-1"
>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>

</div>
</td>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
</th>
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>
Name
</div>
</td>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
</th>
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>
Age
</div>
</td>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
</th>
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>
Gender
</div>
</td>
</th>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
Expand Down Expand Up @@ -1230,44 +1230,44 @@ LoadedCheerio {
<tr
aria-hidden="true"
class="rc-table-measure-row"
style="height: 0px;"
tabindex="-1"
>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>

</div>
</td>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
</th>
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>
Name
</div>
</td>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
</th>
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>
Age
</div>
</td>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
</th>
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>
Gender
</div>
</td>
</th>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
Expand Down Expand Up @@ -1418,44 +1418,44 @@ LoadedCheerio {
<tr
aria-hidden="true"
class="rc-table-measure-row"
style="height: 0px;"
tabindex="-1"
>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>
Name
</div>
</td>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
</th>
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>
Age
</div>
</td>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
</th>
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>
Gender
</div>
</td>
<td
style="padding-top: 0px; padding-bottom: 0px; border-top: 0px; border-bottom: 0px; height: 0px;"
</th>
<th
class="rc-table-measure-cell"
>
<div
style="height: 0px; overflow: hidden; font-weight: bold;"
class="rc-table-measure-cell-content"
>

</div>
</td>
</th>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
Expand Down
Loading