Skip to content

fix(Suggestion): support maxHeight and overflow-y auto for popup scroll - #1983

Merged
kimteayon merged 3 commits into
ant-design:mainfrom
wenzeyu8888-rgb:fix/suggestion-max-height
Jul 23, 2026
Merged

fix(Suggestion): support maxHeight and overflow-y auto for popup scroll#1983
kimteayon merged 3 commits into
ant-design:mainfrom
wenzeyu8888-rgb:fix/suggestion-max-height

Conversation

@wenzeyu8888-rgb

@wenzeyu8888-rgb wenzeyu8888-rgb commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

📋 Description

Fix #1953

Suggestion 选项过多时弹层无限撑高,且底部会被 Sender 遮挡。新增 maxHeight 能力,超出后 overflow-y: auto

🔗 Related Issues

📝 Changes

  • style/index.ts: cascader-menu 添加 maxHeight: 256px + overflowY: auto
  • demo/scroll.tsx + demo/scroll.md: 新增 25+ 选项滚动 demo
  • __tests__/index.test.tsx: 新增 20+ 选项滚动测试

✅ Checklist

  • 20+ 选项滚动 demo
  • 样式测试

Summary by CodeRabbit

  • 新功能

    • 建议列表超过最大高度时支持弹层内部滚动,提升长列表浏览体验。
    • 新增滚动建议示例,展示输入触发、选择建议及提交行为。
  • 测试

    • 增加超过 20 条建议项的展示验证,确保所有选项均可正常呈现。
  • 文档

    • 补充滚动功能的中英文示例说明。

Issue: ant-design#1953

- Add maxHeight: 256px and overflowY: auto to cascader-menu in style
- Add scroll demo with 25+ items
- Add test for 20+ items scroll scenario
@dosubot dosubot Bot added the enhancement New feature or request label Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Suggestion 级联菜单新增最大高度和垂直滚动样式,并添加包含 25 条建议项的滚动演示及对应测试。

Changes

Suggestion 滚动支持

Layer / File(s) Summary
级联菜单滚动样式
packages/x/components/suggestion/style/index.ts
级联菜单容器新增 256px 最大高度和自动垂直滚动。
滚动演示与测试
packages/x/components/suggestion/demo/scroll.tsx, packages/x/components/suggestion/demo/scroll.md, packages/x/components/suggestion/__tests__/index.test.tsx
新增包含 25 条建议项的滚动 Demo,并验证 / 触发后所有选项及级联菜单均渲染。

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

Poem

小兔敲键盘,斜杠唤清单,
二十五项跳进来,
菜单不再长无边,
滚动条轻轻转。
代码新芽真可爱!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning 已补充滚动样式、demo 和测试,但未见修正弹层定位以避免被 Sender 遮挡。 补充弹层定位相关实现或配置,并验证弹层在 Sender 下方不会被遮挡。
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了这次为 Suggestion 弹层增加最大高度与纵向滚动支持的核心改动。
Out of Scope Changes check ✅ Passed 新增的 demo、测试和样式调整都与支持 Suggestion 弹层滚动这一目标一致。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces scroll support for the Suggestion component when options exceed the maximum height. It updates the cascader menu styles to include a maximum height of 256px and vertical scrolling. Additionally, a new demo and a corresponding unit test have been added to demonstrate and verify this scrolling behavior with 25 items. There are no review comments, so I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/x/components/suggestion/style/index.ts (1)

17-18: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

考虑使用设计 Token 替代硬编码尺寸

为了更好地适配未来的自定义主题,建议考虑使用设计 Token(例如 token.controlHeight * 8 等)来替代硬编码的 256px 像素值。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/x/components/suggestion/style/index.ts` around lines 17 - 18, Update
the maxHeight value in the suggestion component style to use the theme design
token, such as token.controlHeight multiplied by the required scale, instead of
the hardcoded 256px value; keep overflowY unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/x/components/suggestion/style/index.ts`:
- Around line 17-18: Update the maxHeight value in the suggestion component
style to use the theme design token, such as token.controlHeight multiplied by
the required scale, instead of the hardcoded 256px value; keep overflowY
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: aa2ab201-eec4-4482-b97b-32f45c608fe3

📥 Commits

Reviewing files that changed from the base of the PR and between 17db20b and 852513a.

📒 Files selected for processing (4)
  • packages/x/components/suggestion/__tests__/index.test.tsx
  • packages/x/components/suggestion/demo/scroll.md
  • packages/x/components/suggestion/demo/scroll.tsx
  • packages/x/components/suggestion/style/index.ts

@wenzeyu8888-rgb

Copy link
Copy Markdown
Contributor Author

#1953

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 23, 2026
@kimteayon
kimteayon merged commit 39c0ac2 into ant-design:main Jul 23, 2026
6 of 7 checks passed
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Bundle Report

Changes will decrease total bundle size by 241.25kB (-6.49%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
x-markdown-array-push 1.37MB -241.29kB (-15.01%) ⬇️
antdx-array-push 2.11MB 43 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: x-markdown-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
latex.min.js (New) 264.89kB 264.89kB 100.0% 🚀
latex.min.css (New) 24.39kB 24.39kB 100.0% 🚀
latex.js (Deleted) -506.18kB 0 bytes -100.0% 🗑️
latex.css (Deleted) -24.39kB 0 bytes -100.0% 🗑️
view changes for bundle: antdx-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antdx.min.js 43 bytes 2.11MB 0.0%

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

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Good First Issue] Suggestion 超出最大高度时支持内部滚动

2 participants