Skip to content

Conversation

@RylanBot
Copy link
Collaborator

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

💡 需求背景和解决方案

📝 更新日志

  • fix(Table): 修复虚拟滚动时,开启合并行的单元格消失的问题

  • 本条 PR 不需要纳入 Changelog

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 18, 2025

tdesign-react-demo

npm i https://pkg.pr.new/tdesign-react@3900

commit: c8e9d5f

@github-actions
Copy link
Contributor

完成

@RylanBot RylanBot requested a review from Copilot October 18, 2025 20:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where cells with rowspan and colspan attributes disappear during virtual scrolling in the Table component. The fix ensures that the rowspan/colspan map is calculated based on the currently visible data rather than the full dataset, and uses useIsomorphicLayoutEffect instead of useEffect to synchronize layout calculations.

Key changes:

  • Updated useRowspanAndColspan hook to use useIsomorphicLayoutEffect for better synchronization with layout updates
  • Changed TBody to pass renderData instead of data to ensure rowspan/colspan calculations work with virtualized data
  • Added debouncing mechanism in useVirtualScroll to prevent rapid consecutive updates during scrolling

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/components/table/hooks/useRowspanAndColspan.ts Switched from useEffect to useIsomorphicLayoutEffect for layout synchronization and added type import
packages/components/table/TBody.tsx Changed to pass renderData instead of data to fix rowspan/colspan with virtual scrolling
packages/components/hooks/useVirtualScroll.ts Added isUpdating flag and scroll position correction logic to prevent update conflicts

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +133 to +139
const targetScrollTop = scrollTop;
setTimeout(() => {
const currentScrollTop = container.current?.scrollTop;
const scrollTopDiff = Math.abs(currentScrollTop - targetScrollTop);
if (scrollTopDiff > 0) {
// eslint-disable-next-line no-param-reassign
container.current.scrollTop = targetScrollTop;
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

The variable targetScrollTop is assigned directly from scrollTop parameter without modification. This intermediate variable adds no value and can be removed - use scrollTop directly in the setTimeout callback.

Suggested change
const targetScrollTop = scrollTop;
setTimeout(() => {
const currentScrollTop = container.current?.scrollTop;
const scrollTopDiff = Math.abs(currentScrollTop - targetScrollTop);
if (scrollTopDiff > 0) {
// eslint-disable-next-line no-param-reassign
container.current.scrollTop = targetScrollTop;
setTimeout(() => {
const currentScrollTop = container.current?.scrollTop;
const scrollTopDiff = Math.abs(currentScrollTop - scrollTop);
if (scrollTopDiff > 0) {
// eslint-disable-next-line no-param-reassign
container.current.scrollTop = scrollTop;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants