fix(Table): apply defaultSortOrder on grouping columns by b84330808 · Pull Request #59611 · ant-design/ant-design · GitHub
Skip to content

fix(Table): apply defaultSortOrder on grouping columns - #59611

Open
b84330808 wants to merge 1 commit into
ant-design:masterfrom
b84330808:fix/30791-group-column-default-sort-order
Open

b84330808 wants to merge 1 commit into
ant-design:masterfrom
b84330808:fix/30791-group-column-default-sort-order

Conversation

@b84330808

Copy link
Copy Markdown

中文版模板 / Chinese template

🤔 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

close #30791

💡 Background and Solution

A grouping column (one with children) can have a sorter, and a controlled sortOrder on it already works. Its defaultSortOrder was ignored, though: collectSortStates only collected the controlled sortOrder for grouping columns, while leaf columns also fall back to defaultSortOrder on init. So a grouping column with sorter and defaultSortOrder: 'descend' rendered unsorted, with no active sort icon.

This adds the same defaultSortOrder branch for grouping columns, with the same init && column.sorter guard as leaf columns. pushState now takes the sort order as an optional argument, so both default branches use it. There's no API change.

The new test in Table.sorter.test.tsx renders a grouping column with sorter and defaultSortOrder: 'descend' and checks the row order and aria-sort. It fails on master and passes with this change. All Table tests pass, and ESLint, Biome and tsc are clean.

I used Claude Code to write this change.

📝 Change Log

Language Changelog
🇺🇸 English Fix Table defaultSortOrder not taking effect on grouping columns.
🇨🇳 Chinese 修复 Table 分组列上设置的 defaultSortOrder 不生效的问题。

A column with children only took part in sorting when it had a controlled
`sortOrder`; its `defaultSortOrder` was ignored. Collect it the same way as
for leaf columns.

close ant-design#30791

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

👁 Visual Regression Report for PR #59611 Passed ✅

🎯 Target branch: master (dc3a92d)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎

🎊 Congrats! No visual-regression diff found.

📖 中文报告

👁 PR #59611 视觉回归报告 通过 ✅

🎯 目标分支: master (dc3a92d)

🎊 恭喜!未发现视觉回归差异。

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Preview is ready

@coderabbitai

coderabbitai Bot commented Oct 20, 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: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1227d864-568e-47b6-9db0-35b642f20483
📥 Commits

Reviewing files that changed from the base of the PR and between dc3a92d and 32a0192.

📒 Files selected for processing: 2
  • components/table/__tests__/Table.sorter.test.tsx
  • components/table/hooks/useSorter.tsx

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

📝 Summary

Summary by CodeRabbit

  • Bug 修复
    • 修复分组列配置默认降序排序时,表格数据未正确降序排列的问题。
    • 修复相关表头无障碍属性未正确显示为 descending 的问题。
    • 统一分组列及其子列的默认排序状态处理。

排序状态初始化现在会处理分组列上的 defaultSortOrder。新增回归测试验证数据按降序排列,且表头的 aria-sort 为 descending。

Changes: 表格排序

Layer / File(s) Summary
分组列默认排序状态
components/table/hooks/useSorter.tsx, components/table/__tests__/Table.sorter.test.tsx
pushState 支持传入排序顺序。初始化时记录分组列的 defaultSortOrder,叶列复用该状态写入逻辑。新增测试验证降序数据和 aria-sort="descending"。

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 32a01

The change is mergeable; grouping-column default sorting uses a consistent state and key.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed 标题准确描述了主要修复内容,即让 Table 分组列支持 defaultSortOrder。标题简洁、明确,并与代码变更和测试内容一致。
Description check Passed 描述与变更内容相关。它说明了分组列的 defaultSortOrder 问题、修复方案、测试覆盖范围和验证结果。
Linked Issues check Passed 直接关联的开放 issue #30791 要求 defaultSortOrder 在非末级的分组列上生效。components/table/hooks/useSorter.tsx 为满足 init && column.sorter && column.defaultSortOrder 的分组列写入默认排序状态,并保留受控 sortOrder 行为。新增测试覆盖带 `children…
Out of Scope Changes check Passed 变更仅包含排序状态收集逻辑和对应的 Table 回归测试。pushState 的可选排序参数用于复用叶列和分组列的默认状态写入逻辑。测试直接验证 issue #30791 的行为。未发现与该 issue 无关的代码或测试变更。
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…
Full details: Linked Issues check

Explanation

直接关联的开放 issue #30791 要求 defaultSortOrder 在非末级的分组列上生效。components/table/hooks/useSorter.tsx 为满足 init &amp;&amp; column.sorter &amp;&amp; column.defaultSortOrder 的分组列写入默认排序状态,并保留受控 sortOrder 行为。新增测试覆盖带 children 的分组列,验证降序行顺序和 aria-sort="descending"。这些改动满足 issue 的编码要求。

Full details: Docstring Coverage

Explanation

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 files.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

兔子翻开表格页,
分组列上落下排序键。
名字排成降序行,
表头亮出 descending。
胡萝卜旁,测试通过啦!

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

@pkg-pr-new

pkg-pr-new Bot commented Oct 20, 2026

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 5.79MB (178.67%) ⬆️⚠️, exceeding the configured threshold of 5%.

Bundle name Size Change
antd.min-array-push 9.03MB 5.79MB (178.67%) ⬆️⚠️

Affected Assets, Files, and Routes:

view changes for bundle: antd.min-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antd-with-locales.js (New) 4.82MB 4.82MB 100.0% 🚀
antd.js (New) 4.21MB 4.21MB 100.0% 🚀
antd-with-locales.min.js (Deleted) -1.81MB 0 bytes -100.0% 🗑️
antd.min.js (Deleted) -1.43MB 0 bytes -100.0% 🗑️

@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

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.

Table defaultSortOrder is invalid when the column is not the last level

1 participant