Skip to content

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

Merged
merged 4 commits into from
May 19, 2025
Merged

update destroyOnClose to destroyOnHidden #475

merged 4 commits into from
May 19, 2025

Conversation

li-jia-nan
Copy link
Member

@li-jia-nan li-jia-nan commented May 18, 2025

Summary by CodeRabbit

  • 文档

    • 将 API 文档和示例中的 destroyOnClose 属性重命名为 destroyOnHidden,并更新相关描述和示例代码。
    • 优化 README.md 表格格式,调整部分空白和排版。
  • 新特性

    • DialogWrap 组件属性由 destroyOnClose 更名为 destroyOnHidden,默认值为 false,语义更清晰。
  • 测试

    • 测试用例同步更新为 destroyOnHidden,并完善类型声明。
  • 杂项

    • 升级 React 及 React DOM 的 TypeScript 类型定义至 19.x,新增 Node.js 类型依赖。
    • 优化部分类型声明和 ref 初始化,提升类型安全性。

Copy link

vercel bot commented May 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dialog ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 18, 2025 3:31am

Copy link

coderabbitai bot commented May 18, 2025

"""

Walkthrough

本次更新主要将对话框组件相关的 destroyOnClose 属性统一重命名为 destroyOnHidden,涉及文档、示例、类型声明、核心组件实现和测试用例。同时,部分 TypeScript 类型声明和 React 相关依赖也进行了升级,代码中的 ref 初始化方式更为规范,提升了类型安全性。

Changes

文件/路径分组 变更摘要
.gitignore 新增忽略 pnpm-lock.yaml 文件。
README.md API 文档属性表重构,destroyOnClose 重命名为 destroyOnHidden,相关描述同步调整。
docs/examples/ant-design.tsx
docs/examples/bootstrap.tsx
示例代码中变量、handler、prop 从 destroyOnClose 重命名为 destroyOnHidden
package.json 升级 @types/react@types/react-dom 到 19.x,新增 @types/node,调整依赖顺序。
src/Dialog/Content/Panel.tsx sentinelStyleentityStyle 增加显式类型,ref 初始化为 null
src/Dialog/Content/index.tsx prop destroyOnClose 改为 destroyOnHidden,ref 初始化为 nulldisplayName 仅在非生产环境赋值。
src/Dialog/index.tsx 多个 React ref 初始化为 null,提升类型安全。
src/DialogWrap.tsx prop 及内部变量 destroyOnClose 全部重命名为 destroyOnHidden,默认值为 false
src/IDialogPropTypes.tsx 类型定义中 destroyOnClose 属性重命名为 destroyOnHidden
tests/index.spec.tsx 测试用例中 destroyOnClose 均重命名为 destroyOnHidden,增加类型注解。
src/Dialog/Content/MemoChildren.tsx children 类型断言由 React.ReactElement 改为更通用的 React.ReactElement<any>

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
Loading

Suggested reviewers

  • thinkasany
  • zombieJ

Poem

小兔挥笔更名忙,
destroyOnClose 说再见,
destroyOnHidden 新登场。
类型升级更安全,
文档示例齐换装。
代码整洁如春草,
兔子鼓掌跳三跳! 🐇✨
"""

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

docs/examples/ant-design.tsx

Oops! 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.tsx

Oops! 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.tsx

Oops! 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.

  • 2 others

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit 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.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit 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 Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5d63120 and 91c0631.

📒 Files selected for processing (5)
  • docs/examples/ant-design.tsx (4 hunks)
  • docs/examples/bootstrap.tsx (3 hunks)
  • src/Dialog/Content/MemoChildren.tsx (1 hunks)
  • src/DialogWrap.tsx (4 hunks)
  • tests/index.spec.tsx (5 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/Dialog/Content/MemoChildren.tsx
🚧 Files skipped from review as they are similar to previous changes (4)
  • docs/examples/bootstrap.tsx
  • docs/examples/ant-design.tsx
  • src/DialogWrap.tsx
  • tests/index.spec.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Commit Unit Tests in branch update-api
  • Post Copyable Unit Tests in 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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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

socket-security bot commented May 18, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​types/​react-dom@​19.1.51001007295100
Added@​types/​react@​19.1.41001007895100

View full report

Copy link

@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: 2

🧹 Nitpick comments (1)
README.md (1)

75-75: 修复拼写错误
将 “compenents” 更正为 “components”。

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f7f399f and 5d63120.

📒 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.lockpackage-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: 类型定义更加明确,属性名称更新

这里有两处改进:

  1. Demo 组件添加了明确的 React 函数组件类型 React.FC<Partial<DialogProps>>
  2. destroyOnClose 属性重命名为 destroyOnHidden

这两项更改提高了代码的类型安全性并保持了命名一致性。


420-422: 改进了类型定义并使用正确的 ref 初始化

这里的改进包括:

  1. Demo 组件添加了明确的 React 函数组件类型 React.FC
  2. 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,确保了整个组件层次结构中属性名称的一致性。

Copy link

codecov bot commented May 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.43%. Comparing base (f7f399f) to head (91c0631).
Report is 2 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zombieJ zombieJ merged commit 855dfe9 into master May 19, 2025
12 checks passed
@zombieJ zombieJ deleted the update-api branch May 19, 2025 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants