Skip to content

Commit

Permalink
fix: Adjust the solution to the sub-level freezing scenario in multip…
Browse files Browse the repository at this point in the history
…le headers
  • Loading branch information
kampiu committed Sep 25, 2023
1 parent d8bcfae commit 029e93f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/utils/fixUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,22 @@ export function getCellFixedInfo<RecordType = any>(
const hasChildren = hasColumnChildren(curColumns);

// no children only
const canLastFix = !(curColumns as ColumnGroupType<RecordType>)?.children || hasChildren;
const canLastFix = !(curColumns as ColumnGroupType<RecordType>)?.children;

if (direction === 'rtl') {
if (fixLeft !== undefined) {
const prevFixLeft = prevColumn && prevColumn.fixed === 'left';
firstFixLeft = !prevFixLeft && canLastFix;
firstFixLeft = !prevFixLeft && (canLastFix || hasChildren);
} else if (fixRight !== undefined) {
const nextFixRight = nextColumn && nextColumn.fixed === 'right';
lastFixRight = !nextFixRight && canLastFix;
lastFixRight = !nextFixRight && (canLastFix || hasChildren);
}
} else if (fixLeft !== undefined) {
const nextFixLeft = nextColumn && nextColumn.fixed === 'left';
lastFixLeft = !nextFixLeft && canLastFix;
} else if (fixRight !== undefined) {
const prevFixRight = prevColumn && prevColumn.fixed === 'right';
firstFixRight = !prevFixRight && canLastFix;
firstFixRight = !prevFixRight && (canLastFix || hasChildren);
}

return {
Expand Down
4 changes: 3 additions & 1 deletion tests/FixedHeader.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ describe('Table.FixedHeader', () => {
const wrapper = mount(<Table columns={columns} data={data} scroll={{ x: true }} />);
await safeAct(wrapper);
expect(wrapper.find('td').at(9).props().className).toContain('rc-table-cell-fix-left-last');
expect(wrapper.find('th').first().props().className).toContain('rc-table-cell-fix-left-last');
expect(wrapper.find('th').first().props().className).not.toContain(
'rc-table-cell-fix-left-last',
);
});
});

0 comments on commit 029e93f

Please sign in to comment.