-
-
Notifications
You must be signed in to change notification settings - Fork 825
透传CascaderProps其他参数 #1110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
透传CascaderProps其他参数 #1110
Conversation
Note Other AI code review bot(s) detectedCodeRabbit 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. 📝 WalkthroughWalkthrough重构 Suggestion 组件公开类型与行为:从 CascaderProps 中 Omit 多项,新增 style/children/open/onOpenChange/items/onSelect/block/styles/classNames;用 useMergedState 管理 open,兼容旧/新 onOpen 回调,强制 multiple=false 并转发其余 props 到 Cascader。 Changes
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)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~35 minutes Poem
✨ Finishing Touches
🧪 Generate 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
-
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. ↩
There was a problem hiding this 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 的行为更加明确和健壮。请查看我的具体建议。
There was a problem hiding this 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
📒 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
vsonDropdownVisibleChange
)的实现是合理的,确保了向后兼容性。
93-95
: 状态管理实现正确使用
useMergedState
来管理open
状态,支持受控和非受控两种模式,实现符合 React 最佳实践。
54-61
: 新增的公共接口属性设计合理新增的
style
、children
、open
、onOpenChange
、items
、onSelect
、block
、styles
、classNames
等属性为组件提供了更精确的类型定义和更好的开发体验。
There was a problem hiding this 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
📒 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
: 新增的公开属性增强了组件的灵活性新增的
style
、children
、open
、onOpenChange
、items
、onSelect
、block
、styles
和classNames
属性为组件提供了更好的自定义能力,这些改动很好地扩展了组件的功能。
171-171
: 显式设置multiple={false}
确保了组件行为的一致性强制禁用多选功能是正确的设计决策,因为
Suggestion
组件的语义就是单选建议。这样可以防止用户通过otherProps
意外启用多选功能。
93-101
: open 状态管理实现合理使用
useMergedState
管理open
状态并通过triggerOpen
函数同步调用onOpenChange
回调,实现了受控和非受控模式的良好支持。
@kimteayon 啥时候有空帮忙合并发布下? |
Bundle ReportChanges will increase total bundle size by 21 bytes (0.02%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: antdx-array-pushAssets Changed:
|
你好需要更新下快照后合并 |
@kimteayon 跑了下test,没有更新 |
![]() |
中文版模板 / Chinese template
🤔 This is a ...
🔗 Related Issues
💡 Background and Solution
📝 Change Log
Summary by CodeRabbit