Skip to content

fix(useAntdTable): defaultCurrent option not applied on initial render#2918

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-useantdtable-defaultcurrent-issue
Draft

fix(useAntdTable): defaultCurrent option not applied on initial render#2918
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-useantdtable-defaultcurrent-issue

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 28, 2026

useAntdTable ignored the defaultCurrent option, always starting pagination at page 1 regardless of the configured value.

Root Cause

_submit's fallback pagination and submit's initial call both hardcoded current: 1 without checking options.defaultCurrent. Since useAntdTable drives initial fetching through _submit (not through usePagination's defaultParams), the defaultCurrent value was never applied.

Fix

Two one-line changes in useAntdTable/index.tsx:

  • _submit fallback: current: 1current: options.defaultCurrent || 1
  • submit initial call: current: 1current: options.defaultCurrent || 1

reset() intentionally retains current: 1 — resetting should always return to page 1.

// Now works as expected
const { tableProps } = useAntdTable(getTableData, { defaultCurrent: 2 });
// Initial request uses current=2

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

[useAntdTable] defaultCurrent parameter not working as expected

💡 需求背景和解决方案

useAntdTabledefaultCurrent 选项未生效,初始分页始终为第 1 页。

原因:_submit 的回退分页参数和 submit 的初始调用均硬编码了 current: 1,未读取 options.defaultCurrent

修复:将上述两处改为 options.defaultCurrent || 1reset() 保持 current: 1 不变(重置应回到第 1 页)。

📝 更新日志

语言 更新描述
🇺🇸 英文 useAntdTable: fix defaultCurrent option being ignored on initial render
🇨🇳 中文 useAntdTable:修复 defaultCurrent 参数在初始渲染时未生效的问题

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

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

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

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Fix defaultCurrent parameter in useAntdTable pagination fix(useAntdTable): defaultCurrent option not applied on initial render Mar 28, 2026
Copilot AI requested a review from crazylxr March 28, 2026 15:18
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.

[useAntdTable] defaultCurrent parameter not working as expected

3 participants