-
-
Notifications
You must be signed in to change notification settings - Fork 194
update destroyTooltipOnHide to destroyOnHidden #495
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: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
""" Walkthrough本次变更主要包括对 Tooltip 组件及其相关示例的类型注解优化、属性命名统一( Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Tooltip
participant Trigger
participant Popup
User->>Tooltip: 传递 destroyOnHidden 属性
Tooltip->>Trigger: 传递 autoDestroy={destroyOnHidden}
Trigger->>Popup: 控制弹层显示/销毁
User->>Tooltip: 触发 onOpenChange/afterOpenChange 事件
Tooltip->>Trigger: 事件重命名同步传递
Suggested reviewers
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. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #495 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 33 33
Branches 12 12
=========================================
Hits 33 33 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
🔭 Outside diff range comments (1)
docs/examples/formError.tsx (1)
11-14
: 🛠️ Refactor suggestion为组件添加泛型以明确 Props 和 State 类型
当前使用as TestState
进行断言,但未在Component
泛型中声明 state 类型,建议改为:class Test extends Component<{}, TestState> { state: TestState = { visible: false, }; // ... }
🧹 Nitpick comments (2)
tests/index.test.tsx (1)
157-158
: 建议移除冗余属性:showArrow
系列测试中添加destroyOnHidden
并不影响箭头渲染逻辑,建议移除以保持测试简洁。Also applies to: 171-172, 186-187, 204-205
src/Tooltip.tsx (1)
119-119
: 类型断言使用在
React.cloneElement
中添加了显式的类型断言as any
,确保类型兼容性。不过,过度使用any
类型会降低类型安全性,建议考虑使用更具体的类型。可以考虑使用更精确的类型而不是
any
,例如:-return React.cloneElement<any>(children, childProps) as any; +return React.cloneElement<React.ReactElement>(children, childProps);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
.dumirc.ts
(1 hunks).gitignore
(1 hunks)README.md
(1 hunks)docs/examples/arrowContent.tsx
(1 hunks)docs/examples/formError.tsx
(1 hunks)docs/examples/onVisibleChange.tsx
(2 hunks)docs/examples/placement.tsx
(2 hunks)docs/examples/point.tsx
(1 hunks)docs/examples/showArrow.tsx
(1 hunks)docs/examples/simple.tsx
(5 hunks)now.json
(0 hunks)package.json
(3 hunks)src/Popup.tsx
(2 hunks)src/Tooltip.tsx
(8 hunks)tests/index.test.tsx
(7 hunks)vercel.json
(1 hunks)
💤 Files with no reviewable changes (1)
- now.json
🔇 Additional comments (40)
.dumirc.ts (1)
21-21
:outputPath
配置已添加:将文档构建产物输出至.doc
目录,符合 Dumi 的自定义输出需求,与整体部署流程保持一致。.gitignore (3)
33-33
: 忽略pnpm-lock.yaml
:项目使用 pnpm 时应忽略对应锁定文件,与其他包管理工具保持一致。
39-39
: 移除.env.local
后多余空格:清理无意义字符,提升.gitignore
可读性。
45-45
: 忽略bun.lockb
:新增 Bun 包管理器锁文件的忽略规则,适配更多包管理环境。vercel.json (1)
1-3
: 添加 Vercel 部署配置文件:新建vercel.json
并指定framework
为umijs
,替换原有now.json
,部署配置准确无误。docs/examples/point.tsx (1)
7-8
: 明确组件类型及初始化ref
:将Test
声明为React.FC
并将scrollRef
初始值设为null
,提升类型安全,与其他示例保持一致。tests/index.test.tsx (3)
96-96
: 更新describe
名称:将测试集从destroyTooltipOnHide
重命名为destroyOnHidden
,保持与组件属性一致。
123-123
: 添加destroyOnHidden
属性测试:在相应用例中加入该属性,验证隐藏后销毁行为符合预期。
324-324
: 抑制并恢复console.error
输出:通过jest.spyOn
和@ts-expect-error
注解,确保多子节点测试不会产生干扰日志并通过 TS 编译。Also applies to: 329-329
docs/examples/formError.tsx (1)
22-23
: 类型注解增强已正确应用
handleChange
方法已添加React.ChangeEvent<HTMLInputElement>
类型注解,逻辑简洁且符合预期。docs/examples/showArrow.tsx (3)
7-15
:styles
常量已正确使用React.CSSProperties
类型注解
显式声明了样式对象的类型,有助于类型安全和代码可读性。
17-20
:rowStyle
常量已正确使用React.CSSProperties
类型注解
对布局样式添加类型注解,保持了与其他示例的一致性。
21-22
: 将Test
组件声明为React.FC
显式使用React.FC
声明函数组件,符合本次 PR 的组件声明规范。docs/examples/placement.tsx (3)
8-16
:styles
常量已正确使用React.CSSProperties
类型注解
显式声明了样式对象的类型,与全局示例保持一致。
18-20
:rowStyle
常量已正确使用React.CSSProperties
类型注解
添加类型注解后更易于维护和阅读。
22-23
: 将Test
组件声明为React.FC
函数组件显式标注为React.FC
,与其他示例统一。README.md (1)
75-97
: API 文档中的destroyTooltipOnHide
已成功重命名为destroyOnHidden
Props
表格已更新,确保无旧属性残留,并对默认值和描述进行了校对。src/Popup.tsx (1)
14-23
: 已将Popup
组件统一声明为React.FC<ContentProps>
并完成 props 解构
组件声明风格与示例文件一致,解构方式也更清晰可读。docs/examples/simple.tsx (5)
10-10
: 类型接口中的属性名称已更新将
TestState
接口中的属性名从destroyTooltipOnHide
更改为destroyOnHidden
,这与组件 API 的变更保持一致。修改后的命名更简洁且语义明确。
22-22
: 状态初始化中的属性名称已更新组件状态初始化中的属性名已从
destroyTooltipOnHide
更改为destroyOnHidden
,确保了与接口定义的一致性。
98-98
: setState 调用中的属性名称已更新
onDestroyChange
方法中setState
调用的属性名已从destroyTooltipOnHide
更改为destroyOnHidden
,保持了整个组件中命名的一致性。
140-140
: UI 标签文本已更新界面中显示的标签文本已从
destroyTooltipOnHide
更改为destroyOnHidden
,确保了 UI 与代码的一致性。
212-212
: Tooltip 组件属性名称已更新传递给
Tooltip
组件的属性名已从destroyTooltipOnHide
更改为destroyOnHidden
,完成了整个文件中命名的统一更新。docs/examples/onVisibleChange.tsx (2)
5-5
: 增加了明确的事件参数类型注解为
preventDefault
函数的事件参数添加了明确的 TypeScript 类型注解React.MouseEvent<HTMLAnchorElement, MouseEvent>
,提高了代码的类型安全性。
19-20
: 改进了 onVisibleChange 方法的类型安全性和代码简洁性
- 为
visible
参数添加了明确的boolean
类型注解- 简化了
setState
调用,使用了更简洁的对象简写语法这些改进提高了代码的可读性和类型安全性。
package.json (4)
34-34
: 改进了文档部署脚本
docs:deploy
脚本现在会先运行docs:build
再进行部署,确保部署前已生成最新的文档。
51-56
: 更新了测试库和类型定义依赖
- 升级了
@testing-library/react
到^16.3.0
- 添加了
@types/node
依赖- 将 React 相关类型更新到 v19 版本
这些更新使项目与 React 19 兼容,并提供了更好的类型支持。
65-66
: 升级 React 依赖到 v19将 React 和 ReactDOM 的开发依赖从 v18 升级到了 v19,与前面的类型定义更新保持一致。
请确认项目中的所有组件和功能在 React 19 下都能正常工作,特别是那些依赖于可能在 React 19 中改变或废弃的 API 的部分。
70-71
: 更新了 React 的 peer 依赖要求将 React 和 ReactDOM 的 peer 依赖从
>=16.9.0
提高到>=18.0.0
,这意味着使用此组件库的项目至少需要 React 18。请确认这个变更是有意为之的,因为它可能影响一些尚未升级到 React 18 的项目。您可能需要在发布说明中特别提醒这一点。
docs/examples/arrowContent.tsx (3)
7-15
: 为样式对象添加了明确的类型注解为
styles
常量添加了明确的React.CSSProperties
类型注解,并移除了之前的类型断言,使代码更加清晰和类型安全。
17-19
: 为 rowStyle 添加了明确的类型注解为
rowStyle
常量添加了明确的React.CSSProperties
类型注解,与styles
常量的类型处理保持一致。
21-21
: 为组件添加了明确的 React.FC 类型将
Test
组件显式标注为 React 函数组件类型React.FC
,提高了代码的类型安全性和可读性。src/Tooltip.tsx (8)
7-7
: 导入语句调整得当移除了不再需要的
forwardRef
导入,并保留了所需的useImperativeHandle
和useRef
hooks。此变更使导入语句更加精简。
38-38
: 属性命名更加一致将
destroyTooltipOnHide
更改为destroyOnHidden
,使命名风格与组件库其他部分保持一致,提高了 API 的一致性。
62-62
: 组件声明方式优化直接使用
React.forwardRef
声明组件,而不是先定义函数再包装,使代码更加简洁清晰。
76-76
: 属性默认值同步更新将默认属性名称从
destroyTooltipOnHide
更新为destroyOnHidden
,保持与接口变更的一致性。
95-95
: 代码格式优化在
restProps
展开后添加空行,提高了代码的可读性。
133-134
: 事件处理器命名更新将
onPopupVisibleChange
和afterPopupVisibleChange
更新为onOpenChange
和afterOpenChange
,使命名更加清晰简洁,并与底层 Trigger 组件保持一致。
137-137
: 属性名称同步更新将
autoDestroy
的值来源从destroyTooltipOnHide
更新为destroyOnHidden
,确保了组件内部保持一致性。
147-149
: 组件导出格式优化闭合括号与导出语句分开,提高了代码的可读性。
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: 3
🧹 Nitpick comments (3)
.github/workflows/site-deploy.yml (3)
3-7
: 建议限定标签触发模式
当前on.push.tags: ['*']
会对所有标签进行部署,可能引发误触。建议使用严格的语义版本格式(例如v*.*.*
),以只对发布版本的标签触发构建。
23-25
: 确认生成 package-lock.json 步骤的必要性
如果仓库已包含package-lock.json
,npm i --package-lock-only --ignore-scripts
这一步只是重新生成锁文件,可考虑移除以加快 CI;如因特殊需求保留,请在注释中说明原因。
32-33
: 升级 peaceiris/actions-gh-pages Action 版本(可选)
建议将peaceiris/actions-gh-pages@v3
升级到最新的@v4
版本,以获取新功能和安全修复:- uses: peaceiris/actions-gh-pages@v3 + uses: peaceiris/actions-gh-pages@v4🧰 Tools
🪛 actionlint (1.7.7)
33-33: the runner of "peaceiris/actions-gh-pages@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/site-deploy.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/site-deploy.yml
16-16: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
19-19: the runner of "actions/setup-node@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
33-33: the runner of "peaceiris/actions-gh-pages@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
Summary by CodeRabbit
新功能
文档
重构
依赖升级
杂项