fix: Cascader page scroll to top on first open with defaultValue#55890
fix: Cascader page scroll to top on first open with defaultValue#55890yoyo837 merged 1 commit intoant-design:masterfrom
Conversation
|
|
👁 Visual Regression Report for PR #55890 Passed ✅
🎊 Congrats! No visual-regression diff found.
|
📝 WalkthroughSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. 概览升级 改动
代码审查工作量估算🎯 1 (平凡) | ⏱️ ~3 分钟
诗
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
package.json(1 hunks)
🧰 Additional context used
🧠 Learnings (10)
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Use `ant-design/cssinjs` as the styling solution
Applied to files:
package.json
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to **/*.{ts,tsx} : Prefer antd built-in components over external dependencies
Applied to files:
package.json
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to components/**/style/*.ts : Use `ant-design/cssinjs` for all styling
Applied to files:
package.json
📚 Learning: 2025-11-13T02:52:08.942Z
Learnt from: meet-student
Repo: ant-design/ant-design PR: 55697
File: components/drawer/index.tsx:86-88
Timestamp: 2025-11-13T02:52:08.942Z
Learning: In Ant Design components (components/**/*.{ts,tsx}), always use `import useId from 'rc-util/lib/hooks/useId'` instead of `React.useId()` for generating unique IDs, to ensure compatibility with React 16-19. The rc-util hook automatically uses the native implementation in React 18+ and provides a fallback for older versions.
Applied to files:
package.json
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/demo/*.tsx : Demo code import order: React → dependencies → antd components → custom components → types → styles
Applied to files:
package.json
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Support React 16 ~ 19 versions
Applied to files:
package.json
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to **/*.{ts,tsx} : Follow import order: React → dependencies → antd components → custom components → types → styles
Applied to files:
package.json
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to components/**/style/*.ts : Use design tokens from the Ant Design token system
Applied to files:
package.json
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/*.{ts,tsx} : Use CSS transitions for simple animations, rc-motion for complex animations
Applied to files:
package.json
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Ensure sufficient color contrast and do not rely on color alone to convey information
Applied to files:
package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
- GitHub Check: Socket Security: Pull Request Alerts
- GitHub Check: build preview
- GitHub Check: size
- GitHub Check: test lib/es module (es, 2/2)
- GitHub Check: test lib/es module (es, 1/2)
- GitHub Check: build
- GitHub Check: test-react-latest (dom, 2/2)
- GitHub Check: test-react-latest (dom, 1/2)
- GitHub Check: test-node
- GitHub Check: test-react-legacy (18, 1/2)
- GitHub Check: lint
- GitHub Check: test-react-legacy (18, 2/2)
- GitHub Check: visual-diff snapshot (1/2)
- GitHub Check: visual-diff snapshot (2/2)
- GitHub Check: build
| "@ant-design/icons": "^6.1.0", | ||
| "@ant-design/react-slick": "~1.1.2", | ||
| "@rc-component/cascader": "~1.7.0", | ||
| "@rc-component/cascader": "~1.8.0", |
There was a problem hiding this comment.
🧩 Analysis chain
更新 @rc-component/cascader 到 v1.8.0 以修复滚动问题。
依赖版本升级从 ~1.7.0 到 1.8.0 以修复问题 #55820(设置 defaultValue 时首次打开 Cascader 导致页面滚动到顶部)。版本约束使用波浪号()表示兼容的小版本更新是适当的。
请验证以下几点:
- 确认无破坏性变更:请确认 @rc-component/cascader v1.7.0 到 v1.8.0 之间不存在破坏性变更
- 检查 Ant Design 代码:由于这是依赖更新,请确认 Ant Design 的 Cascader 包装器或相关组件无需进行相应的代码变更
- 验证修复:确认此版本升级确实解决了问题 [Cascader] 设置 defaultValue 时首次打开会导致页面滚动到顶部 #55820 中描述的页面滚动问题
可以运行以下脚本检查 Ant Design 是否在任何地方直接依赖于 @rc-component/cascader 的内部实现:
🏁 Script executed:
#!/bin/bash
# 检查 Cascader 组件是否依赖 rc-component/cascader 的内部实现
# 搜索 Cascader 相关的导入和使用
rg -n "@rc-component/cascader" --type=ts --type=tsx components/
# 检查 Cascader 组件是否有特殊的内部处理
rg -n "cascader" --type=ts --type=tsx components/cascader/ -iLength of output: 55
🏁 Script executed:
#!/bin/bash
# 检查 Cascader 组件是否依赖 rc-component/cascader 的内部实现(修正命令)
# 搜索所有导入 @rc-component/cascader 的文件
echo "=== Searching for @rc-component/cascader imports ==="
rg -n "@rc-component/cascader" components/ --type=ts -A 2 -B 2
# 使用文件通配符查找 cascader 组件
echo -e "\n=== Finding cascader component files ==="
fd "cascader" components/ --type f
# 检查 cascader 目录中的内容和导入
echo -e "\n=== Checking cascader directory implementation ==="
rg -n "import.*from" components/cascader/ --type=ts -A 1Length of output: 18087
🌐 Web query:
@rc-component/cascader v1.8.0 changelog breaking changes
💡 Result:
I couldn't find a published @rc-component/cascader v1.8.0 or any changelog entry for v1.8.0. The scoped package on npm lists v1.6.1 (recent) and jsDelivr shows latest 1.7.0 — no 1.8.0 release/changelog is available. [1][2]
Would you like me to search the repository's GitHub releases/tags for unreleased/PR notes or check a specific registry?
Sources:
- npm package page (@rc-component/cascader) — shows v1.6.1. [1]
- jsDelivr package listing (@rc-component/cascader) — shows v1.7.0 as latest known. [2]
🌐 Web query:
@rc-component/cascader npm latest version 2024 2025
💡 Result:
- @rc-component/cascader — latest published version: 1.7.0 (jsDelivr). [1]
- For comparison, the unscoped package rc-cascader had 3.x releases (e.g. 3.30.0 in Dec 2024 and 3.34.0 in 2025). [2][3]
Sources:
[1] jsDelivr package page for @rc-component/cascader (shows v1.7.0).
[2] npm package page for @rc-component/cascader (version listing / recent publishes).
[3] rc-cascader (unscoped) npm/jsdocs pages (shows 3.30.0 / 3.34.0 releases).
@rc-component/cascader v1.8.0 不存在于 npm,无法安装此依赖。
当前 package.json 第 118 行指定的 ~1.8.0 版本在 npm 中尚未发布。根据公开的 npm 注册表和 jsDelivr 的信息,@rc-component/cascader 的最新发布版本是 1.7.0。
需要修正以下之一:
- 更正版本号为已发布的版本(例如
~1.7.0) - 等待 @rc-component/cascader v1.8.0 在 npm 上发布后再提交此 PR
🤖 Prompt for AI Agents
In package.json around line 118 replace the non-existent
"@rc-component/cascader": "~1.8.0" entry with a published version or defer the
change; specifically update the version to a released tag such as "~1.7.0" (or
another confirmed published version) and then regenerate/update the lockfile
(package-lock.json or yarn.lock) before committing, or alternatively wait until
v1.8.0 is published and then set the dependency to that version.
More templates
commit: |
Bundle ReportChanges will decrease total bundle size by 78 bytes (-0.0%) ⬇️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: antd.min-array-pushAssets Changed:
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #55890 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 803 803
Lines 14812 14812
Branches 3913 3913
=========================================
Hits 14812 14812 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|


中文版模板 / Chinese template
🤔 This is a ...
🔗 Related Issues
Fixes #55820
💡 Background and Solution
#55820
📝 Change Log