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(table): 修复虚拟列表maxHeight无法支持字符串问题(#2846) #2847

Merged
merged 6 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions .changeset/rude-baboons-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/table": patch
---

fix(table): 修复虚拟列表 maxHeight 无法支持字符串问题
8 changes: 4 additions & 4 deletions packages/ui/table/src/TableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ export const TableBody = forwardRef<HTMLDivElement | null, TableBodyProps>(
// TODO: avg和summay row的逻辑

const realHeight = scrollBodyElementRef.current?.getBoundingClientRect().height
const maxHeightNumStr = String(maxHeight).replace(/px$/, '')
const vMaxHeight = maxHeight
? !isNaN(Number(String(maxHeight).replace(/px/, '')))
? Number(maxHeight)
? !isNaN(Number(maxHeightNumStr))
? Number(maxHeightNumStr)
: realHeight
: 300

return (
<div
ref={scrollBodyElementRef}
Expand All @@ -87,7 +87,7 @@ export const TableBody = forwardRef<HTMLDivElement | null, TableBodyProps>(
style={{ height: 2, marginTop: -1, background: 'transparent', width: rowWidth }}
></div>
{isArrayNonEmpty(transitionData) ? (
<div style={{ width: '100%', position: 'sticky', left: 0 }}>
<div style={{ width: '100%', position: 'sticky', left: 0, maxHeight: maxHeight, overflow: 'auto' }}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

设置 overflow: 'auto' 后会出现双滚动条

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maxHeight 设置 calc() 时会出现双滚动条

<VirtualList
prefixCls={`${cls}--virtual`}
data={transitionData}
Expand Down