Skip to content

fix: Cascader page scroll to top on first open with defaultValue#55890

Merged
yoyo837 merged 1 commit intoant-design:masterfrom
tuzixiangs:chore(cascader)/fix-55820
Nov 25, 2025
Merged

fix: Cascader page scroll to top on first open with defaultValue#55890
yoyo837 merged 1 commit intoant-design:masterfrom
tuzixiangs:chore(cascader)/fix-55820

Conversation

@tuzixiangs
Copy link
Contributor

中文版模板 / 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

Fixes #55820

💡 Background and Solution

#55820

📝 Change Log

Language Changelog
🇺🇸 English Fix Cascader page scroll to top on first open with defaultValue
🇨🇳 Chinese 修复 Cascader 设置 defaultValue 时首次打开导致页面滚动到顶部的问题。

@bolt-new-by-stackblitz
Copy link

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

@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

Preview is ready

@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

👁 Visual Regression Report for PR #55890 Passed ✅

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

🎊 Congrats! No visual-regression diff found.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 25, 2025

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • 更新了 "@rc-component/cascader" 依赖版本,从 "~1.7.0" 升级到 "~1.8.0"

✏️ Tip: You can customize this high-level summary in your review settings.

概览

升级 @rc-component/cascader 依赖版本从 ~1.7.0 至 ~1.8.0,以修复级联选择器设置 defaultValue 时页面滚动位置异常的问题。

改动

队列 / 文件 改动说明
依赖版本更新
package.json
@rc-component/cascader 依赖版本从 ~1.7.0 更新至 ~1.8.0

代码审查工作量估算

🎯 1 (平凡) | ⏱️ ~3 分钟

  • 这是一个简单的版本号更新,属于日常维护性改动
  • 建议确认新版本的更新日志涵盖了级联选择器的滚动位置修复

🐰 一纸版本升呼啦,
瀑布般的滚动不再来,
defaultValue 心安定,
级联菜单展笑颜,
小兔为你把虫除!✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning 拉取请求标题与其实际目的不一致。标题声称是修复级联选择器首次打开时的页面滚动问题,但实际变更只是更新依赖版本号。 建议将标题更新为 'chore: upgrade @rc-component/cascader to v1.8.0' 以准确反映真实变更内容。
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The PR description is related to the changeset as it references issue #55820 about fixing Cascader's page scroll behavior when opened with defaultValue, which is addressed by the dependency upgrade.
Linked Issues check ✅ Passed The PR upgrades @rc-component/cascader to v1.8.0 to fix issue #55820 regarding unwanted page scrolling when opening Cascader with defaultValue, directly addressing the linked issue's requirements.
Out of Scope Changes check ✅ Passed The changeset contains only the intended dependency upgrade from v1.7.0 to v1.8.0 with no extraneous modifications, keeping the change within scope of fixing issue #55820.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@tuzixiangs tuzixiangs changed the title chore: upgrade @rc-component/cascader to v1.8.0 chore: Fix Cascader page scroll to top on first open with defaultValue Nov 25, 2025
@meet-student meet-student changed the title chore: Fix Cascader page scroll to top on first open with defaultValue fix: Cascader page scroll to top on first open with defaultValue Nov 25, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a26733f and f937fbf.

📒 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",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

更新 @rc-component/cascader 到 v1.8.0 以修复滚动问题。

依赖版本升级从 ~1.7.0 到 1.8.0 以修复问题 #55820(设置 defaultValue 时首次打开 Cascader 导致页面滚动到顶部)。版本约束使用波浪号()表示兼容的小版本更新是适当的。

请验证以下几点:

  1. 确认无破坏性变更:请确认 @rc-component/cascader v1.7.0 到 v1.8.0 之间不存在破坏性变更
  2. 检查 Ant Design 代码:由于这是依赖更新,请确认 Ant Design 的 Cascader 包装器或相关组件无需进行相应的代码变更
  3. 验证修复:确认此版本升级确实解决了问题 [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/ -i

Length 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 1

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 25, 2025

@codecov
Copy link

codecov bot commented Nov 25, 2025

Bundle Report

Changes will decrease total bundle size by 78 bytes (-0.0%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antd.min-array-push 3.89MB -78 bytes (-0.0%) ⬇️

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.min.js -39 bytes 2.14MB -0.0%
antd.min.js -39 bytes 1.75MB -0.0%

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 25, 2025
@yoyo837 yoyo837 merged commit 8b536eb into ant-design:master Nov 25, 2025
45 checks passed
@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a26733f) to head (f937fbf).
⚠️ Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Cascader] 设置 defaultValue 时首次打开会导致页面滚动到顶部

2 participants