Skip to content

fix(table): fix row hover with expanded offset rowSpan#1488

Open
jiangrong-devops wants to merge 1 commit into
react-component:masterfrom
jiangrong-devops:fix/table
Open

fix(table): fix row hover with expanded offset rowSpan#1488
jiangrong-devops wants to merge 1 commit into
react-component:masterfrom
jiangrong-devops:fix/table

Conversation

@jiangrong-devops
Copy link
Copy Markdown

@jiangrong-devops jiangrong-devops commented May 13, 2026

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

N/A

💡 Background and Solution

Background
Chinese

  • 在将表格全部展开时出现鼠标移入存在同级展开的元素行后 hover 会扩散到其他非当前视觉焦点链条上,导致 hover 得不到预期效果,仅在 expand-sticky 中发现该行为,其余示例 hover 表现符合预期

English

  • When all table rows are expanded, hovering over a row containing elements at the same expansion level causes the hover effect to propagate to other elements that are not currently in the visual focus chain, resulting in the hover effect not behaving as expected. This behavior was observed only in the expand-sticky case; in all other examples, the hover behavior was as expected.

Playground

image image

📝 Change Log

Language Changelog
🇺🇸 English fix row hover with expanded offset rowSpan
🇨🇳 Chinese 修复展开行时 rowSpan 偏移导致的悬停问题

Summary by CodeRabbit

发行说明

  • Bug 修复

    • 改进了表格展开行时的行悬停效果,确保悬停范围计算正确
  • 测试

    • 添加了新的测试用例,验证展开行不会影响悬停范围的正确性

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 13, 2026

@jiangrong-devops is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0b69efd4-47e7-4d27-bbe6-872d9a6ceac5

📥 Commits

Reviewing files that changed from the base of the PR and between d5b5bb1 and e463d06.

📒 Files selected for processing (5)
  • src/Body/BodyRow.tsx
  • src/Cell/index.tsx
  • src/VirtualTable/VirtualCell.tsx
  • tests/ExpandedOffset.spec.tsx
  • tests/Hover.spec.tsx

演进概览

该PR为表格组件引入了hoverRowSpan属性,在展开行有行偏移时独立控制悬停范围,防止渲染的rowSpan修改影响悬停样式应用的单元格范围。

变更

展开行悬停范围解耦

层级 / 文件 摘要
Cell属性合约定义
src/Cell/index.tsx
CellProps接口中添加可选的@private hoverRowSpan?: number属性。
BodyRow中的hoverRowSpan计算和转发
src/Body/BodyRow.tsx
getCellProps在展开行偏移条件下计算hoverRowSpan值并返回,BodyRow对每个单元格进行destructuring并转发到Cell组件。
VirtualCell中的hoverRowSpan转发
src/VirtualTable/VirtualCell.tsx
VirtualCellgetCellProps获取hoverRowSpan并将其传递给Cell组件。
Cell组件中的悬停范围应用
src/Cell/index.tsx
Cell计算mergedHoverRowSpan(默认为mergedRowSpan),并用于悬停状态初始化和onMouseEnter范围计算。
测试和导入更新
tests/ExpandedOffset.spec.tsx, tests/Hover.spec.tsx
修正导入源,添加hoverClassName常量,引入新的悬停测试验证展开行偏移不影响悬停范围。

可能相关的PR

  • react-component/table#1284:两个PR都修改了src/Body/BodyRow.tsxgetCellPropsexpandedRowOffset的处理——本PR添加hoverRowSpan用于调整悬停范围,而关联PR调整了展开行的rowSpan

建议的审核者

  • afc163
  • zombieJ

诗歌

🐰 展开行不再困扰
悬停范围独立运作
hoverRowSpan解耦艺术
单元格样式准确无误
表格编辑乐趣无穷


🎯 2 (Simple) | ⏱️ ~12 分钟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰准确地描述了主要变更:修复展开行时由于行偏移(expandedRowOffset)导致的rowSpan行悬停问题。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a fix to ensure that row hover states remain accurate when expanded row offsets are used in the table. It adds a 'hoverRowSpan' property to handle row span calculations independently from the layout row span, which is modified by expanded rows. The changes are implemented across 'BodyRow', 'Cell', and 'VirtualCell' components, and verified with a new test case in 'Hover.spec.tsx'. I have no feedback to provide as there were no review comments.

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.

1 participant