Skip to content

Conversation

guxingke201
Copy link

@guxingke201 guxingke201 commented Aug 12, 2025

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

  • Describe the source of related requirements, such as links to relevant issue discussions.
  • For example: close #xxxx, fix #xxxx

💡 Background and Solution

  • The specific problem to be addressed.
  • List the final API implementation and usage if needed.
  • If there are UI/interaction changes, consider providing screenshots or GIFs.

📝 Change Log

Language Changelog
🇺🇸 English
🇨🇳 Chinese

Summary by CodeRabbit

  • 新功能
    • 支持受控打开状态(open/onOpenChange)、新增 onSelect、items、block、styles、classNames、style、children 等属性,支持自定义 children 渲染。
  • 变更
    • 组件内部维护并同步 open 状态,统一为单选模式(强制多选禁用),未声明的额外属性将安全透传至下层组件。
  • 重大变更
    • 不再接受若干旧属性(如 multiple、value、options、showSearch、defaultValue、fieldNames、onChange、optionRender、onDropdownVisibleChange、dropdownMatchSelectWidth、rootClassName、placement 等)。

Copy link
Contributor

coderabbitai bot commented Aug 12, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

重构 Suggestion 组件公开类型与行为:从 CascaderProps 中 Omit 多项,新增 style/children/open/onOpenChange/items/onSelect/block/styles/classNames;用 useMergedState 管理 open,兼容旧/新 onOpen 回调,强制 multiple=false 并转发其余 props 到 Cascader。

Changes

Cohort / File(s) Summary
Suggestion API 与状态控制重构
components/suggestion/index.tsx
修改 SuggestionProps<T> 为 `Omit<CascaderProps, 'children'

Sequence Diagram(s)

sequenceDiagram
  participant U as 用户
  participant S as Suggestion
  participant C as Cascader

  U->>S: 请求打开/关闭
  S->>S: useMergedState 更新 open
  S->>C: 传入 props (open, multiple=false, ...otherProps)
  Note over S: 根据 isNewAPI 绑定回调
  C-->>S: 打开态变更回调
  S->>S: 更新合并的 open 并触发外部 onOpenChange
  U->>C: 选择项
  C-->>S: onChange(path)
  S->>S: 取 path 最后值,关闭下拉
  S-->>U: 触发 onSelect(value)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~35 minutes

Poem

兔耳轻点代码间,
新旧回调手相牵。
合并开合心自定,
单选玲珑不纷然。
慢步赏花笑颜甜。

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

github-actions bot commented Aug 12, 2025

Preview is ready

Copy link

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

Choose a reason for hiding this comment

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

Summary of Changes

Hello @guxingke201, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求通过使 Suggestion 组件能够透明地传递 Ant Design Cascader 组件的其他属性来增强其功能。这一更改显著增加了 Suggestion 组件的灵活性和可配置性,允许开发人员利用更多的 Cascader 功能,而无需直接修改 Suggestion 的核心逻辑。此更新涉及完善组件的属性接口并实现属性转发机制。

Highlights

  • 属性转发: SuggestionProps 接口现在扩展了 CascaderProps,允许 Suggestion 组件接受并将 Ant Design Cascader 组件中任何未处理的属性直接传递给其内部的 Cascader 实例。
  • 接口优化: 为了保持 Suggestion 组件的预期行为并防止属性冲突,CascaderProps 中的特定属性(如 children、onChange、value 和 options)被明确地从 SuggestionProps 中省略。
  • 默认行为: Suggestion 内部的 Cascader 组件现在明确设置了 multiple={false},确保它在单选模式下运行,这与 Suggestion 组件的设计保持一致。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dosubot dosubot bot added the javascript Pull requests that update Javascript code label Aug 12, 2025
Copy link

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

Choose a reason for hiding this comment

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

Code Review

你好,感谢你的贡献。这个 PR 通过扩展 CascaderProps 并透传其他属性,增强了 Suggestion 组件的灵活性,这是一个很好的改进。我在代码中发现了一个可以改进的地方,主要是关于如何处理 block prop 和透传的 dropdownMatchSelectWidth prop 之间的潜在冲突。通过将 dropdownMatchSelectWidth 添加到 Omit 列表中,可以使 block prop 的行为更加明确和健壮。请查看我的具体建议。

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

♻️ Duplicate comments (1)
components/suggestion/index.tsx (1)

31-49: 扩展 Omit 列表以保持 API 一致性

当前的 SuggestionProps 接口通过 Omit 排除了多个 CascaderProps,但应该考虑添加更多属性以确保 Suggestion 组件的行为可预测且一致。

根据之前的评审意见,建议将 dropdownMatchSelectWidth 添加到 Omit 列表中,因为 Suggestion 组件已经通过 block prop 来控制此行为(见第 178 行)。如果允许用户通过 ...otherProps 直接传递此属性,可能会覆盖 block 的设置。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed85c30 and a604014.

📒 Files selected for processing (1)
  • components/suggestion/index.tsx (5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
components/suggestion/index.tsx (1)
components/index.ts (1)
  • SuggestionProps (25-25)
🔇 Additional comments (4)
components/suggestion/index.tsx (4)

170-170: 显式设置 multiple={false} 的实现正确

通过显式设置 multiple={false} 来强制单选模式是正确的做法,确保了组件的行为符合设计预期。


153-163: API 兼容性处理实现良好

通过版本检测来兼容新旧 API(onOpenChange vs onDropdownVisibleChange)的实现是合理的,确保了向后兼容性。


93-95: 状态管理实现正确

使用 useMergedState 来管理 open 状态,支持受控和非受控两种模式,实现符合 React 最佳实践。


54-61: 新增的公共接口属性设计合理

新增的 stylechildrenopenonOpenChangeitemsonSelectblockstylesclassNames 等属性为组件提供了更精确的类型定义和更好的开发体验。

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: 0

♻️ Duplicate comments (1)
components/suggestion/index.tsx (1)

31-49: 需要将 dropdownMatchSelectWidth 添加到 Omit 列表中

为了确保 Suggestion 组件的 block prop 行为一致且可预测,建议将 dropdownMatchSelectWidth 保留在 Omit 列表中(当前第45行已包含)。这样可以防止用户通过 ...otherProps 覆盖由 block prop 控制的下拉宽度匹配行为。

🧹 Nitpick comments (1)
components/suggestion/index.tsx (1)

166-180: 属性展开顺序可能导致意外覆盖

当前 ...otherProps 在第167行展开,位于其他显式属性之前。虽然这种顺序允许组件的核心属性覆盖 otherProps 中的同名属性,但建议在代码注释中明确说明这种设计意图,以提高代码的可维护性。

在第167行上方添加注释说明:

 return wrapCSSVar(
   <Cascader
+    // otherProps 先展开,确保核心属性不会被意外覆盖
     {...otherProps}
     options={itemList}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a604014 and 472a397.

📒 Files selected for processing (1)
  • components/suggestion/index.tsx (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
components/suggestion/index.tsx (1)
components/index.ts (1)
  • SuggestionProps (25-25)
🔇 Additional comments (3)
components/suggestion/index.tsx (3)

53-61: 新增的公开属性增强了组件的灵活性

新增的 stylechildrenopenonOpenChangeitemsonSelectblockstylesclassNames 属性为组件提供了更好的自定义能力,这些改动很好地扩展了组件的功能。


171-171: 显式设置 multiple={false} 确保了组件行为的一致性

强制禁用多选功能是正确的设计决策,因为 Suggestion 组件的语义就是单选建议。这样可以防止用户通过 otherProps 意外启用多选功能。


93-101: open 状态管理实现合理

使用 useMergedState 管理 open 状态并通过 triggerOpen 函数同步调用 onOpenChange 回调,实现了受控和非受控模式的良好支持。

@guxingke201
Copy link
Author

@kimteayon 啥时候有空帮忙合并发布下?

@guxingke201 guxingke201 reopened this Aug 14, 2025
Copy link

codecov bot commented Aug 14, 2025

Bundle Report

Changes will increase total bundle size by 21 bytes (0.02%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antdx-array-push 139.74kB 21 bytes (0.02%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: antdx-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antdx.min.js 21 bytes 139.74kB 0.02%

@kimteayon
Copy link
Collaborator

@kimteayon 啥时候有空帮忙合并发布下?

你好需要更新下快照后合并

@guxingke201
Copy link
Author

@kimteayon 啥时候有空帮忙合并发布下?

你好需要更新下快照后合并

@kimteayon 跑了下test,没有更新

@guxingke201
Copy link
Author

image @kimteayon @afc163 啥时候有空帮忙合并下,顺便发布下,没改dom结构,快照试了下没有更新

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants