Skip to content

update destroyOnClose to destroyOnHidden #481

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 1 commit into from
May 19, 2025
Merged

update destroyOnClose to destroyOnHidden #481

merged 1 commit 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

  • 新功能

    • 将抽屉组件的属性名从 destroyOnClose 更名为 destroyOnHidden,以更准确地反映内容销毁的时机。
  • 文档

    • 示例文档同步更新了属性名。
  • 样式

    • 代码风格进行了小幅优化,提升了可读性和一致性。
  • 测试

    • 所有相关测试用例已同步更新为新属性名,确保行为一致。
  • 杂项

    • 新增开发依赖 @types/node

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)
drawer ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 18, 2025 2:40am

Copy link

coderabbitai bot commented May 18, 2025

Walkthrough

本次更改主要将 Drawer 组件及其相关用例中的 destroyOnClose 属性统一重命名为 destroyOnHidden,并同步调整了相关类型定义、测试代码和示例文档。同时,对部分组件声明方式进行了类型增强和代码风格优化,新增了 @types/node 开发依赖。

Changes

文件/路径分组 变更摘要
docs/examples/forceRender.tsx 示例代码将 Drawer 的 destroyOnClose 属性更名为 destroyOnHidden。
package.json devDependencies 增加 @types/node@^22.15.18。
src/Drawer.tsx DrawerProps 接口及 Drawer 组件相关属性从 destroyOnClose 更名为 destroyOnHidden,并做了少量代码风格优化。
src/DrawerPanel.tsx DrawerPanel 组件声明方式改为 React.FC<Readonly>,增强类型安全。
src/DrawerPopup.tsx DrawerPopup 组件由普通函数声明改为 React.ForwardRefRenderFunction 箭头函数写法。
tests/index.spec.tsx 所有 destroyOnClose 测试用例及属性重命名为 destroyOnHidden,测试逻辑不变。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Drawer
    participant DrawerPanel
    participant DrawerPopup

    User->>Drawer: 设置 destroyOnHidden 属性
    Drawer->>DrawerPopup: 渲染 DrawerPopup
    DrawerPopup->>DrawerPanel: 渲染 DrawerPanel
    Drawer-->>User: 根据 destroyOnHidden 控制内容销毁时机
Loading

Poem

🐰
属性新名随风转,
Drawer 隐藏再销散。
测试同步不慌乱,
类型安全更周全。
代码如春草,
细雨润新篇。

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/forceRender.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1405:15)
    at require.resolve (node:internal/modules/helpers:145:19)
    at Object. (/.eslintrc.js:2:21)
    at Module._compile (node:internal/modules/cjs/loader:1734:14)
    at Object..js (node:internal/modules/cjs/loader:1899:10)
    at Module.load (node:internal/modules/cjs/loader:1469:32)
    at Module._load (node:internal/modules/cjs/loader:1286:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.require (node:internal/modules/cjs/loader:1491:12)
src/DrawerPanel.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1405:15)
    at require.resolve (node:internal/modules/helpers:145:19)
    at Object. (/.eslintrc.js:2:21)
    at Module._compile (node:internal/modules/cjs/loader:1734:14)
    at Object..js (node:internal/modules/cjs/loader:1899:10)
    at Module.load (node:internal/modules/cjs/loader:1469:32)
    at Module._load (node:internal/modules/cjs/loader:1286:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.require (node:internal/modules/cjs/loader:1491:12)
src/Drawer.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1405:15)
    at require.resolve (node:internal/modules/helpers:145:19)
    at Object. (/.eslintrc.js:2:21)
    at Module._compile (node:internal/modules/cjs/loader:1734:14)
    at Object..js (node:internal/modules/cjs/loader:1899:10)
    at Module.load (node:internal/modules/cjs/loader:1469:32)
    at Module._load (node:internal/modules/cjs/loader:1286:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.require (node:internal/modules/cjs/loader:1491:12)
  • 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.

✨ 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

codecov bot commented May 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (5b54804) to head (64dfd60).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #481   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            5         5           
  Lines          146       145    -1     
  Branches        54        54           
=========================================
- Hits           146       145    -1     

☔ 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.

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: 0

🧹 Nitpick comments (3)
src/Drawer.tsx (2)

98-98: 使用箭头函数简化 Context 创建

使用更简洁的箭头函数语法重构 refContext 创建逻辑,提高代码可读性。


113-113: 改进代码格式

在 eventHandlers 对象和 drawerPopupProps 声明之间添加空行,提高代码可读性。

docs/examples/forceRender.tsx (1)

52-52: 按钮文本需要更新

按钮文本仍然显示为 "Destroy On Close",建议更新为 "Destroy On Hidden" 以保持与新属性名称的一致性。

-        <Button onClick={() => setOpen2(true)}>Destroy On Close</Button>
+        <Button onClick={() => setOpen2(true)}>Destroy On Hidden</Button>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5b54804 and 64dfd60.

📒 Files selected for processing (6)
  • docs/examples/forceRender.tsx (1 hunks)
  • package.json (1 hunks)
  • src/Drawer.tsx (4 hunks)
  • src/DrawerPanel.tsx (1 hunks)
  • src/DrawerPopup.tsx (2 hunks)
  • tests/index.spec.tsx (1 hunks)
🔇 Additional comments (11)
package.json (1)

59-59: 添加 Node.js 类型定义包

添加 @types/node 开发依赖以支持 Node.js 的 TypeScript 类型定义,有助于提升代码开发体验和类型安全性。

src/DrawerPanel.tsx (1)

36-36: 组件类型定义优化

将普通函数组件重构为使用 React.FC<Readonly<DrawerPanelProps>> 的形式,增强了类型安全性并确保了 props 的不可变性。这种写法更符合现代 React 开发规范。

src/DrawerPopup.tsx (2)

80-83: 重构组件为 ForwardRefRenderFunction

将 DrawerPopup 组件重构为使用 React.ForwardRefRenderFunction 的箭头函数形式,提高了类型安全性和代码一致性。这种方式更明确地表达了组件的 ref 转发意图。


381-381: 函数结尾符号更新

箭头函数语法变更导致的结尾符号从大括号变为分号加大括号,与上述组件定义方式变更相对应。

src/Drawer.tsx (3)

24-24: 属性名称重命名:destroyOnClose → destroyOnHidden

destroyOnClose 属性重命名为 destroyOnHidden,名称更准确地反映了组件的实际行为 - 在抽屉隐藏时销毁组件,而不仅仅是关闭时。


44-44: 解构赋值中的属性名称更新

与接口定义保持一致,更新了属性解构中的名称为 destroyOnHidden


101-101: 条件判断中使用更新后的属性名

在条件渲染逻辑中将 destroyOnClose 更新为 destroyOnHidden,确保功能与之前保持一致。

docs/examples/forceRender.tsx (1)

35-35: 属性名称已正确更新

已将 destroyOnClose 属性更新为 destroyOnHidden,符合组件 API 的更新。

tests/index.spec.tsx (3)

186-186: 测试描述块名称已正确更新

描述块名称已从 destroyOnClose 更新为 destroyOnHidden,与组件 API 的变更保持一致。


188-190: 测试案例中的属性名已正确更新

测试案例中的 destroyOnClose 属性已更新为 destroyOnHidden,保持了与组件 API 变更的一致性。


196-200: 内联渲染测试中的属性名已正确更新

使用 getContainer={false} 的内联渲染测试中,destroyOnClose 属性已正确更新为 destroyOnHidden

@yoyo837
Copy link
Member

yoyo837 commented May 18, 2025

rc的不需要做废弃直接改吗?

@li-jia-nan
Copy link
Member Author

rc的不需要做废弃直接改吗?

不需要,废弃逻辑在 antd 侧

@zombieJ zombieJ merged commit 7a7d873 into master May 19, 2025
12 checks passed
@zombieJ zombieJ deleted the update-api branch May 19, 2025 06:34
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.

3 participants