Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: VirtualTable should auto collapse if items is less than scrollY #1020

Merged
merged 2 commits into from
Sep 12, 2023
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
282 changes: 140 additions & 142 deletions docs/examples/virtual.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,154 +12,152 @@ interface RecordType {
}

const columns: ColumnsType = [
{ title: 'title1', dataIndex: 'a', key: 'a', width: 100 },
{ title: 'title1', dataIndex: 'a', key: 'a', width: 800 },
{ title: 'title1', dataIndex: 'a', key: 'a', width: 100 },
// { title: 'title2', dataIndex: 'b', key: 'b', width: 100, fixed: 'left', ellipsis: true },
// {
// title: 'title3',
// dataIndex: 'c',
// key: 'c',
// onCell: (_, index) => {
// if (index % 4 === 0) {
// return {
// rowSpan: 3,
// };
// }
{ title: 'title1', dataIndex: 'a', key: 'a', width: 100, fixed: 'left' },
{ title: 'title2', dataIndex: 'b', key: 'b', width: 100, fixed: 'left', ellipsis: true },
{
title: 'title3',
dataIndex: 'c',
key: 'c',
onCell: (_, index) => {
if (index % 4 === 0) {
return {
rowSpan: 3,
};
}

// if (index % 4 === 3) {
// return {
// rowSpan: 1,
// colSpan: 3,
// };
// }
if (index % 4 === 3) {
return {
rowSpan: 1,
colSpan: 3,
};
}

// return {
// rowSpan: 0,
// };
// },
// },
// {
// title: 'title4',
// key: 'd',
// children: [
// // Children columns
// {
// title: 'title4-1',
// dataIndex: 'b',
// onCell: (_, index) => {
// if (index % 4 === 0) {
// return {
// colSpan: 3,
// };
// }
return {
rowSpan: 0,
};
},
},
{
title: 'title4',
key: 'd',
children: [
// Children columns
{
title: 'title4-1',
dataIndex: 'b',
onCell: (_, index) => {
if (index % 4 === 0) {
return {
colSpan: 3,
};
}

// if (index % 4 === 3) {
// return {
// colSpan: 0,
// };
// }
// },
// },
// {
// title: 'title4-2',
// dataIndex: 'b',
// onCell: (_, index) => {
// if (index % 4 === 0 || index % 4 === 3) {
// return {
// colSpan: 0,
// };
// }
// },
// },
// ],
// },
// {
// title: 'title6',
// dataIndex: 'b',
// key: 'f',
// onCell: (_, index) => {
// if (index % 4 === 0) {
// return {
// rowSpan: 0,
// colSpan: 0,
// };
// }
if (index % 4 === 3) {
return {
colSpan: 0,
};
}
},
},
{
title: 'title4-2',
dataIndex: 'b',
onCell: (_, index) => {
if (index % 4 === 0 || index % 4 === 3) {
return {
colSpan: 0,
};
}
},
},
],
},
{
title: 'title6',
dataIndex: 'b',
key: 'f',
onCell: (_, index) => {
if (index % 4 === 0) {
return {
rowSpan: 0,
colSpan: 0,
};
}

// if (index % 4 === 1) {
// return {
// rowSpan: 3,
// };
// }
if (index % 4 === 1) {
return {
rowSpan: 3,
};
}

// return {
// rowSpan: 0,
// };
// },
// },
// {
// title: (
// <div>
// title7
// <br />
// <br />
// <br />
// Hello world!
// </div>
// ),
// dataIndex: 'bk',
// key: 'g',
// },
// {
// title: 'title8',
// dataIndex: 'b',
// onCell: (_, index) => {
// if (index % 2 === 0) {
// return {
// rowSpan: 2,
// colSpan: 2,
// };
// }
return {
rowSpan: 0,
};
},
},
{
title: (
<div>
title7
<br />
<br />
<br />
Hello world!
</div>
),
dataIndex: 'bk',
key: 'g',
},
{
title: 'title8',
dataIndex: 'b',
onCell: (_, index) => {
if (index % 2 === 0) {
return {
rowSpan: 2,
colSpan: 2,
};
}

// return {
// rowSpan: 0,
// };
// },
// },
// {
// title: 'title9 i',
// dataIndex: 'b',
// key: 'i',
// onCell: () => ({
// colSpan: 0,
// }),
// },
// { title: 'title10', dataIndex: 'b', key: 'j' },
// {
// title: 'title11',
// dataIndex: 'b',
// key: 'k',
// width: 50,
// fixed: 'right',
// onCell: (_, index) => {
// return {
// rowSpan: index % 2 === 0 ? 2 : 0,
// // colSpan: 2,
// };
// },
// },
// {
// title: 'title12',
// dataIndex: 'b',
// key: 'l',
// width: 100,
// fixed: 'right',
// onCell: () => {
// return {
// // colSpan: 0,
// };
// },
// },
return {
rowSpan: 0,
};
},
},
{
title: 'title9 i',
dataIndex: 'b',
key: 'i',
onCell: () => ({
colSpan: 0,
}),
},
{ title: 'title10', dataIndex: 'b', key: 'j' },
{
title: 'title11',
dataIndex: 'b',
key: 'k',
width: 50,
fixed: 'right',
onCell: (_, index) => {
return {
rowSpan: index % 2 === 0 ? 2 : 0,
// colSpan: 2,
};
},
},
{
title: 'title12',
dataIndex: 'b',
key: 'l',
width: 100,
fixed: 'right',
onCell: () => {
return {
// colSpan: 0,
};
},
},
];

export function cleanOnCell(cols: any = []) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"classnames": "^2.2.5",
"rc-resize-observer": "^1.1.0",
"rc-util": "^5.36.0",
"rc-virtual-list": "^3.10.4"
"rc-virtual-list": "^3.10.7"
},
"devDependencies": {
"@rc-component/father-plugin": "^1.0.2",
Expand Down
1 change: 1 addition & 0 deletions src/VirtualTable/BodyGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ const Grid = React.forwardRef<GridRef, GridProps>((props, ref) => {
if (flattenData.length) {
bodyContent = (
<VirtualList<FlattenData<any>>
fullHeight={false}
ref={listRef}
className={classNames(tblPrefixCls, `${tblPrefixCls}-virtual`)}
height={scrollY}
Expand Down
Loading