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

[Table] Tabs 组件中的表格设置 maxHeight 属性,非默认 Tab 下的表格的表尾行显示不正常 #3365

Closed
cdevq opened this issue Feb 15, 2025 · 2 comments
Labels
to be published fixed, not be published

Comments

@cdevq
Copy link

cdevq commented Feb 15, 2025

tdesign-react 版本

1.10.5

重现链接

https://codesandbox.io/p/sandbox/h3x8pz

重现步骤

访问:https://codesandbox.io/p/sandbox/h3x8pz

期望结果

点击 Table2 后,Table2 的表尾显示效果应该与 Table1 一样。也就是如图

Image

实际结果

No response

框架版本

No response

浏览器版本

Chrome(133.0.6943.59)

系统版本

Window10(22H2)

Node版本

No response

补充说明

No response

Copy link
Contributor

👋 @cdevq,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@wonkzhang
Copy link
Contributor

wonkzhang commented Feb 18, 2025

这个问题已经定位到原因了,table在初始化后,会调用useEffect,动态计算表格滚动高度等变量,来动态设置isFixedHeader变量(暂且叫它悬浮变量),如果悬浮变量为true的时候,会在表格页脚(footer)上增加fixed定位的样式,这样咱们就能看到底部的总数表页脚了。

现在的问题是,楼主的这种写法,第二个TabPanel下的table在useEffect执行的时候,滚动高度为0(因为内容尚未初始化),导致悬浮变量是false,所以就看不到页脚。

至于楼主说的,此刻点击排序就能看到页脚汇总行,是因为排序会引起useEffect重新执行,此刻滚动高度是正常的数值(大于0),所以悬浮变量的值为true。

有一种快速解决的方案(以下为伪代码):

const [activeKey, setActiveKey] = useState();
TabPanel onChange={key=>setActiveKey(key)}
TableAffixDemo activekey={activeKey}

通过切换Tab的时候,强制更新组件的方式可暂时解决问题。

至于本组件的代码修复,我来跟进吧。

wonkzhang added a commit to wonkzhang/tdesign-react that referenced this issue Feb 19, 2025
修复tabs切换的时候表格table的footer可能不显示的问题

fix Tencent#3365
@uyarn uyarn added the to be published fixed, not be published label Feb 19, 2025
@uyarn uyarn closed this as completed in e917392 Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to be published fixed, not be published
Projects
None yet
Development

No branches or pull requests

3 participants