Skip to content

fix: keep className and style from onHeaderRow - #1521

Open
vicuts wants to merge 1 commit into
react-component:masterfrom
vicuts:fix/header-row-class-style
Open

vicuts wants to merge 1 commit into
react-component:masterfrom
vicuts:fix/header-row-class-style

Conversation

@vicuts

@vicuts vicuts commented Oct 14, 2026 •

Copy link
Copy Markdown

Summary

className and style returned by onHeaderRow never reach the header <tr>. Other props such as id still do. antd passes onHeaderRow straight through (antd master pins ~1.11.1), so an antd Table whose onHeaderRow returns a className or style renders the header row without them.

Since #1261 (b10f4d4) HeaderRow renders:

<RowComponent {...rowProps} className={classNames.row} style={styles.row}>

The explicit props come after the spread, so they always replace the values from onHeaderRow, even when classNames.header.row and styles.header.row are not set. The bug is in every release from 1.3.0 to 1.12.0.

This change merges the two sources the same way BodyRow already does for onRow: the onHeaderRow value first, then the semantic one. className stays undefined when both are empty, so the existing snapshots do not change.

The pre-commit prettier hook also wrapped the long onHeaderCell line in the same file. #1516 makes the same change to that line, and a local git merge-tree against its head merges cleanly.

Tests

Two cases next to renders onHeaderRow correctly in tests/Table.spec.jsx:

  • onHeaderRow returns a className and a style, and both are on thead tr
  • the same together with classNames.header.row and styles.header.row, and all four values are on thead tr

Verification

  • Both new tests fail on master (no my-header-row class, empty style.color) and pass with this change
  • npm test: 21 files passed, 238 tests passed, no snapshot changes
  • npm run tsc
  • npm run lint: 0 errors, the same 23 warnings as on master, none in the changed files
  • prettier --check and git diff --check on the changed files

Summary by CodeRabbit

  • 问题修复
    • 表头行现在会合并回调提供的类名与样式,并保留组件配置的类名与样式;同名样式属性以组件配置为准。

@vercel

vercel Bot commented Oct 14, 2026

Copy link
Copy Markdown

@vicuts is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 61f8537b-0831-4519-a63a-fe856f1b34d8
📥 Commits

Reviewing files that changed from the base of the PR and between e63fbf5 and 4b1098e.

📒 Files selected for processing: 2
  • src/Header/HeaderRow.tsx
  • tests/Table.spec.jsx

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

表头行现在会合并 onHeaderRow 返回的类名和样式。新增测试验证回调属性的应用,以及它们与语义类名和样式的共存。

Changes

表头行属性合并

Layer / File(s) Summary
合并表头行属性
src/Header/HeaderRow.tsx, tests/Table.spec.jsx
表头行的类名合并 onHeaderRow 返回的 className 与语义类名;样式合并回调返回的 style 与语义样式,冲突时由语义样式覆盖。新增测试验证属性应用和共存。

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 4b109

表头行现在会同时保留 onHeaderRow 提供的类名和样式以及语义行属性。现有证据未显示会影响用户或发布的具体问题,可按常规检查合并。

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 拉取请求标题为「fix: keep className and style from onHeaderRow」。标题清晰、简洁,直接描述了变更的主要内容:保留 onHeaderRow 返回的 className 和 style 属性。标题与代码变更相符,反映了在 HeaderRow 组件中实现的修复,即合并 onHeaderRow 回调返回的样式属性与语义样式值。
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
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.
✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed due to a network error.

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.

This branch has not been deployed

No deployments
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