-
-
Notifications
You must be signed in to change notification settings - Fork 947
fix: 修复 Skill 组件 Tooltip 子元素必须为 React 元素的问题 #1533
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
Conversation
📝 Walkthrough高级概览在 Skill.tsx 中调整了标题的条件渲染逻辑,使用 Tooltip 组件进行包装。当存在 toolTip 属性时,在 Tooltip 中嵌套标题元素;否则直接渲染。内部 DOM 结构改变,但保留原有视觉表现和交互行为。 变更内容
代码审查工作量评估🎯 1 (琐碎) | ⏱️ ~5 分钟
诗歌
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Repository UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)📓 Common learnings⏰ 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). (3)
🔇 Additional comments (1)
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 |
Summary of ChangesHello @Chiaki-xps, 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! 此拉取请求旨在修复 Highlights
Using Gemini Code AssistThe 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 by creating a comment using either
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 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
|
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
你好,感谢你的贡献。这个修复是正确且必要的。antd 的 Tooltip 组件要求其子节点是一个单一的 React 元素,以便附加事件处理器和 ref。如此前直接传递字符串会导致 React.Children.only 报错。通过将 mergeTitle 包装在 <span> 中,你确保了 Tooltip 总是接收一个有效的 React 元素作为子节点,这有效地解决了问题。代码改动清晰、简洁,没有发现其他问题。做得很好!
Bundle ReportChanges will increase total bundle size by 1.26MB (41.48%) ⬆️
Affected Assets, Files, and Routes:view changes for bundle: x-markdown-array-pushAssets Changed:
view changes for bundle: antdx-array-pushAssets Changed:
|
| const titleNode = toolTip ? <Tooltip {...toolTip}>{mergeTitle}</Tooltip> : mergeTitle; | ||
| const titleNode = toolTip ? ( | ||
| <Tooltip {...toolTip}> | ||
| <span>{mergeTitle}</span> |
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.
antd 版本是啥,按道理 Tooltip 会自动处理这种情况。
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.
当前的main分支跑测试用例的时候出现这个问题
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.
当前x的antd是6.1。我看看antd是不是又这个问题
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.
现在应该不会有这个问题 之前有这个问题是因为 @ant-design/tools 没升级 本地合并下 main 重新安装依赖跑下就好了
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1533 +/- ##
=======================================
Coverage 94.69% 94.69%
=======================================
Files 137 137
Lines 3960 3962 +2
Branches 1123 1118 -5
=======================================
+ Hits 3750 3752 +2
Misses 207 207
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|

根据本次修复内容,以下是中文 PR 模板:
🤔 这个变动的性质是?
🔗 相关 Issue
修复 Sender 组件中 Skill 使用 Tooltip 时测试用例报错的问题。
💡 需求背景和解决方案
问题描述:
Skill 组件在使用
toolTip属性时,Tooltip的子元素直接传入字符串,导致Tooltip内部的Trigger组件调用React.Children.only时抛出错误:解决方案:
将
Tooltip的子元素用<span>包裹,确保传入的是 React 元素而非纯字符串。📝 更新日志
Summary by CodeRabbit
发布说明
✏️ Tip: You can customize this high-level summary in your review settings.