Skip to content

Commit

Permalink
Merge branch 'react-component:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
yezhonghu0503 authored Oct 28, 2024
2 parents 7bf2a08 + 26f9746 commit 38d1147
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-table",
"version": "7.48.0",
"version": "7.48.1",
"description": "table ui component for react",
"engines": {
"node": ">=8.x"
Expand Down
5 changes: 4 additions & 1 deletion src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,10 @@ function Table<RecordType extends DefaultRecordType>(
const measureTarget = currentTarget || scrollHeaderRef.current;
if (measureTarget) {
const scrollWidth =
typeof mergedScrollX === 'number' ? mergedScrollX : measureTarget.scrollWidth;
// Should use mergedScrollX in virtual table(useInternalHooks && tailor === true)
useInternalHooks && tailor && typeof mergedScrollX === 'number'
? mergedScrollX
: measureTarget.scrollWidth;
const clientWidth = measureTarget.clientWidth;
// There is no space to scroll
if (scrollWidth === clientWidth) {
Expand Down
34 changes: 34 additions & 0 deletions tests/FixedColumn.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,38 @@ describe('Table.FixedColumn', () => {
expect(container.querySelectorAll('.rc-table-cell-fix-right-first').length).toBe(101);
expect(container).toMatchSnapshot();
});

it('right shadow should be shown when scrollX is less than the sum of the widths of all columns', async () => {
const wrapper = mount(
<Table
columns={[
{ title: 'a', width: 200, fixed: 'left' },
{ title: 'b', width: 200 },
{ title: 'c', width: 200 },
{ title: 'd', width: 200, fixed: 'right' },
]}
data={data}
scroll={{ x: 100 }}
style={{ width: 400 }}
/>,
);

await safeAct(wrapper);
// Use `onScroll` directly since simulate not support `currentTarget`
act(() => {
wrapper
.find('.rc-table-content')
.props()
.onScroll({
currentTarget: {
scrollLeft: 10,
scrollWidth: 800,
clientWidth: 400,
},
} as any);
});
wrapper.update();
expect(wrapper.find('.rc-table').hasClass('rc-table-ping-left')).toBeTruthy();
expect(wrapper.find('.rc-table').hasClass('rc-table-ping-right')).toBeTruthy();
});
});
2 changes: 1 addition & 1 deletion tests/__snapshots__/ExpandRow.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ LoadedCheerio {
exports[`Table.Expand > renders fixed column correctly > work 1`] = `
LoadedCheerio {
"0": <div
class="rc-table rc-table-ping-right rc-table-fixed-column rc-table-scroll-horizontal rc-table-has-fix-left rc-table-has-fix-right"
class="rc-table rc-table-fixed-column rc-table-scroll-horizontal rc-table-has-fix-left rc-table-has-fix-right"
>
<div
class="rc-table-container"
Expand Down
8 changes: 4 additions & 4 deletions tests/__snapshots__/FixedColumn.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ LoadedCheerio {
exports[`Table.FixedColumn > renders correctly > scrollX - with data 1`] = `
LoadedCheerio {
"0": <div
class="rc-table rc-table-ping-right rc-table-fixed-column rc-table-scroll-horizontal rc-table-has-fix-left rc-table-has-fix-right"
class="rc-table rc-table-fixed-column rc-table-scroll-horizontal rc-table-has-fix-left rc-table-has-fix-right"
>
<div
class="rc-table-container"
Expand Down Expand Up @@ -1642,7 +1642,7 @@ LoadedCheerio {
exports[`Table.FixedColumn > renders correctly > scrollX - without data 1`] = `
LoadedCheerio {
"0": <div
class="rc-table rc-table-ping-right rc-table-fixed-column rc-table-scroll-horizontal rc-table-has-fix-left rc-table-has-fix-right"
class="rc-table rc-table-fixed-column rc-table-scroll-horizontal rc-table-has-fix-left rc-table-has-fix-right"
>
<div
class="rc-table-container"
Expand Down Expand Up @@ -1931,7 +1931,7 @@ LoadedCheerio {
exports[`Table.FixedColumn > renders correctly > scrollXY - with data 1`] = `
LoadedCheerio {
"0": <div
class="rc-table rc-table-ping-right rc-table-fixed-header rc-table-fixed-column rc-table-scroll-horizontal rc-table-has-fix-left rc-table-has-fix-right"
class="rc-table rc-table-fixed-header rc-table-fixed-column rc-table-scroll-horizontal rc-table-has-fix-left rc-table-has-fix-right"
>
<div
class="rc-table-container"
Expand Down Expand Up @@ -2804,7 +2804,7 @@ LoadedCheerio {
exports[`Table.FixedColumn > renders correctly > scrollXY - without data 1`] = `
LoadedCheerio {
"0": <div
class="rc-table rc-table-ping-right rc-table-fixed-header rc-table-fixed-column rc-table-scroll-horizontal rc-table-has-fix-left rc-table-has-fix-right"
class="rc-table rc-table-fixed-header rc-table-fixed-column rc-table-scroll-horizontal rc-table-has-fix-left rc-table-has-fix-right"
>
<div
class="rc-table-container"
Expand Down

0 comments on commit 38d1147

Please sign in to comment.