-
-
Notifications
You must be signed in to change notification settings - Fork 195
update destroyOnClose to destroyOnHidden #475
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
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
""" Walkthrough本次更新主要将对话框组件相关的 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant DialogWrap
participant Dialog
participant Content
User->>DialogWrap: 设置 destroyOnHidden={true}
DialogWrap->>Dialog: 传递 destroyOnHidden
Dialog->>Content: 传递 destroyOnHidden
Content-->>Dialog: 根据 destroyOnHidden 判断是否卸载子组件
Dialog-->>DialogWrap: 动画结束后根据 destroyOnHidden 决定是否移除 DOM
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
docs/examples/ant-design.tsxOops! Something went wrong! :( ESLint: 7.32.0 ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. docs/examples/bootstrap.tsxOops! Something went wrong! :( ESLint: 7.32.0 ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. src/Dialog/Content/MemoChildren.tsxOops! Something went wrong! :( ESLint: 7.32.0 ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (4)
✨ 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.
|
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: 2
🧹 Nitpick comments (1)
README.md (1)
75-75
: 修复拼写错误
将 “compenents” 更正为 “components”。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
.gitignore
(2 hunks)README.md
(1 hunks)docs/examples/ant-design.tsx
(4 hunks)docs/examples/bootstrap.tsx
(3 hunks)package.json
(1 hunks)src/Dialog/Content/Panel.tsx
(2 hunks)src/Dialog/Content/index.tsx
(3 hunks)src/Dialog/index.tsx
(2 hunks)src/DialogWrap.tsx
(3 hunks)src/IDialogPropTypes.tsx
(1 hunks)tests/index.spec.tsx
(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/Dialog/Content/index.tsx (1)
src/Dialog/Content/Panel.tsx (1)
PanelRef
(28-31)
src/Dialog/index.tsx (1)
src/Dialog/Content/index.tsx (1)
ContentRef
(12-12)
🪛 GitHub Actions: ✅ test
tests/index.spec.tsx
[error] 388-388: TypeScript error TS2698: Spread types may only be created from object types.
🔇 Additional comments (28)
src/Dialog/Content/Panel.tsx (3)
9-14
: 添加了明确的类型注解,提高了类型安全性为
sentinelStyle
常量添加了明确的React.CSSProperties
类型注解,使类型定义更加清晰,有助于提高代码的可维护性和类型安全性。
16-18
: 添加了明确的类型注解,提高了类型安全性为
entityStyle
常量添加了明确的React.CSSProperties
类型注解,使类型定义更加清晰,有助于提高代码的可维护性和类型安全性。
64-65
: 改进了ref的初始化方式,提高了类型安全性将
useRef
钩子明确初始化为null
而不是未初始化状态,这符合React的最佳实践并提高了类型安全性。.gitignore (2)
37-37
: 添加pnpm锁文件到忽略列表将
pnpm-lock.yaml
添加到忽略列表中,与现有的yarn.lock
和package-lock.json
忽略模式保持一致,确保不同包管理器的锁文件都被正确排除在版本控制之外。
52-52
: 添加Bun锁文件到忽略列表将
bun.lockb
添加到忽略列表中,确保Bun包管理器的锁文件被排除在版本控制之外,与其他包管理器的处理方式保持一致。src/IDialogPropTypes.tsx (1)
23-23
: 属性重命名:destroyOnClose 改为 destroyOnHidden将接口中的属性名从
destroyOnClose
更改为destroyOnHidden
,使命名更加准确和一致。这项更改与PR的主要目标一致,即在整个代码库中统一使用destroyOnHidden
命名。src/Dialog/Content/index.tsx (5)
28-28
: 属性重命名:destroyOnClose 改为 destroyOnHidden将解构的属性名从
destroyOnClose
更改为destroyOnHidden
,与整个代码库中的命名保持一致,使API命名更加准确。
35-35
: 改进了ref的初始化方式,提高了类型安全性将
dialogRef
明确初始化为null
而不是未初始化状态,这符合React的最佳实践并提高了类型安全性。
37-37
: 改进了ref的初始化方式,提高了类型安全性将
panelRef
明确初始化为null
而不是未初始化状态,这符合React的最佳实践并提高了类型安全性。
73-73
: 属性重命名:使用重命名后的属性作为CSSMotion的prop将
CSSMotion
组件的removeOnLeave
属性的值从destroyOnClose
更改为destroyOnHidden
,保持与重命名一致。
92-94
: 优化生产环境构建添加了环境检查条件,仅在非生产环境下设置
Content.displayName
,这有助于减小生产环境代码的体积,是React组件的最佳实践。src/Dialog/index.tsx (2)
58-60
: 初始化 refs 初始值为 null 以提升类型安全性
将未初始化的 ref 统一设置为null
,避免了undefined
的类型风险,符合最佳实践。
118-118
: 初始化 contentTimeoutRef 为 null 以保证一致性
显式将contentTimeoutRef
初始值设置为null
,与其他 ref 初始化保持一致,提升可维护性。docs/examples/bootstrap.tsx (3)
14-14
: 状态变量命名正确更新为 destroyOnHidden
将destroyOnClose
重命名为destroyOnHidden
并初始化为false
,与 API 一致。
24-26
: 事件处理函数名同步更新
将onDestroyOnHiddenChange
与状态名保持一致,变更逻辑清晰且与示例中其他处理函数规范一致。
31-31
: Dialog 组件 prop 重命名正确
将destroyOnClose
改为destroyOnHidden
,与最新的属性定义保持一致。package.json (2)
62-62
: 确认 devDependencies 中 @rc-component/select 位置调整无误
仅变动了条目顺序,版本保持一致,无需额外调整。
67-69
: TypeScript 与 Node 类型声明版本升级合理
添加了@types/node@^22.15.18
并将@types/react
、@types/react-dom
升级至 19.x,以匹配 React 19 类型,支持更高的类型安全。README.md (1)
52-57
: API 文档属性表已更新为 destroyOnHidden
成功将属性重命名并统一描述,与代码实现保持一致。docs/examples/ant-design.tsx (3)
34-34
: 状态变量命名正确更新为 destroyOnHidden
将destroyOnClose
重命名为destroyOnHidden
并初始化为false
,与 API 保持一致。
63-65
: 事件处理函数名同步更新
将onDestroyOnHiddenChange
与状态名保持一致,逻辑清晰,无额外问题。
100-100
: Dialog 组件 prop 重命名正确
将destroyOnClose
改为destroyOnHidden
,与最新的属性定义一致。tests/index.spec.tsx (3)
116-116
: 将 destroyOnClose 重命名为 destroyOnHidden测试描述块的名称已从
destroyOnClose
更改为destroyOnHidden
,这与整个代码库中的属性重命名保持一致。
131-132
: 类型定义更加明确,属性名称更新这里有两处改进:
- 为
Demo
组件添加了明确的 React 函数组件类型React.FC<Partial<DialogProps>>
- 将
destroyOnClose
属性重命名为destroyOnHidden
这两项更改提高了代码的类型安全性并保持了命名一致性。
420-422
: 改进了类型定义并使用正确的 ref 初始化这里的改进包括:
- 为
Demo
组件添加了明确的 React 函数组件类型React.FC
- 为
inputRef
添加了明确的类型React.useRef<HTMLInputElement>(null)
,并用null
正确初始化这些变更遵循了 React 中的最佳实践,提高了代码的类型安全性和可维护性。
src/DialogWrap.tsx (3)
21-21
: 将 destroyOnClose 重命名为 destroyOnHidden属性名称从
destroyOnClose
更改为destroyOnHidden
,默认值为false
。这个名称更准确地反映了该属性的功能 - 即在对话框隐藏时销毁内容,而不仅仅是关闭时。
36-36
: 更新条件判断中的属性名称将条件判断中的
destroyOnClose
更改为destroyOnHidden
,保持了整个组件中命名的一致性。这个条件判断负责在对话框隐藏且设置了销毁选项时移除包装的 div。
50-50
: 将传递给 Dialog 组件的属性重命名将传递给
Dialog
组件的属性从destroyOnClose
更新为destroyOnHidden
,确保了整个组件层次结构中属性名称的一致性。
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #475 +/- ##
==========================================
+ Coverage 98.42% 98.43% +0.01%
==========================================
Files 8 8
Lines 190 192 +2
Branches 64 66 +2
==========================================
+ Hits 187 189 +2
Misses 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit
文档
destroyOnClose
属性重命名为destroyOnHidden
,并更新相关描述和示例代码。新特性
DialogWrap
组件属性由destroyOnClose
更名为destroyOnHidden
,默认值为false
,语义更清晰。测试
destroyOnHidden
,并完善类型声明。杂项