Skip to content

fix: Modal hooks with render function#53994

Merged
zombieJ merged 3 commits intomasterfrom
fix-hooks
Jun 4, 2025
Merged

fix: Modal hooks with render function#53994
zombieJ merged 3 commits intomasterfrom
fix-hooks

Conversation

@zombieJ
Copy link
Copy Markdown
Member

@zombieJ zombieJ commented Jun 3, 2025

中文版模板 / Chinese template

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

fix #53992

💡 Background and Solution

  • The specific problem to be addressed.
  • List the final API implementation and usage if needed.
  • If there are UI/interaction changes, consider providing screenshots or GIFs.

📝 Change Log

Language Changelog
🇺🇸 English Fix Modal hooks call update not support update function.
🇨🇳 Chinese 修复 Modal hooks 的 update 不支持更新函数的问题。

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2025

📝 Walkthrough

Summary by CodeRabbit

  • 测试

    • 新增并完善了关于弹窗更新功能的测试用例,提升了测试覆盖率和准确性。
  • 新功能

    • 弹窗支持通过函数式方式动态更新配置,提升了配置更新的灵活性。
  • 文档

    • 无用户可见文档变更。
  • 其他

    • 不影响用户体验的类型优化和内部实现调整。
      """

Summary by CodeRabbit

  • 新功能

    • 模态框现在支持通过函数方式动态更新配置,实现更灵活的内容与标题修改。
  • Bug 修复

    • 优化了模态框操作队列,确保仅在实例准备就绪后执行相关操作,提升了稳定性。
  • 测试

    • 增强了模态框的测试用例,验证了多次更新内容与标题的正确性。

Walkthrough

本次更改为 Modal 组件的 HookModal 实现了通过函数式参数更新配置的能力,调整了类型定义和更新逻辑,并增强了相关测试用例。此外,actionQueue 机制被优化,确保只有在 modal 实例可用时才执行相关操作。

Changes

文件/分组 变更摘要
components/modal/useModal/HookModal.tsx HookModalRef 的 update 方法类型由对象参数改为支持函数式参数,内部实现支持函数式更新配置。
components/modal/confirm.tsx ConfigUpdate 类型由私有改为导出,允许外部引用。
components/modal/useModal/index.tsx actionQueue 状态类型由 (() => void)[] 改为 VoidFunction[],简化 update 调用的类型断言。
components/modal/tests/hook.test.tsx 测试用例增加函数式 update 测试,断言 title 和 content 更新。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HookModal
    participant ModalInstance

    User->>HookModal: 调用 update((prev) => {...})
    HookModal->>HookModal: 判断参数类型
    alt 参数为函数
        HookModal->>HookModal: 使用 prevConfig 计算新配置
    else 参数为对象
        HookModal->>HookModal: 合并配置
    end
    HookModal->>ModalInstance: 更新配置并渲染
Loading

Assessment against linked issues

Objective Addressed Explanation
支持 HookModal 的 update 方法接收函数式参数,实现 prevConfig 到新配置的更新 (#53992)
update 方法类型声明与实现与静态 confirm 保持一致 (#53992)
测试覆盖函数式 update 行为,确保正确更新配置 (#53992)

Assessment against linked issues: Out-of-scope changes

(无发现超出需求范围的代码更改)

Poem

小兔写代码,Modal 功能新,
update 支持函数,配置巧更新。
actionQueue 守护,时机正当真,
测试再加固,稳健又安心。
Modal 弹窗里,灵活如小云 ☁️
"""


📜 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 23fe5d6 and 8b0eee8.

📒 Files selected for processing (3)
  • components/modal/__tests__/hook.test.tsx (2 hunks)
  • components/modal/useModal/HookModal.tsx (3 hunks)
  • components/modal/useModal/index.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • components/modal/useModal/index.tsx
  • components/modal/tests/hook.test.tsx
  • components/modal/useModal/HookModal.tsx
⏰ Context from checks skipped due to timeout of 90000ms (14)
  • GitHub Check: visual-diff snapshot (1/2)
  • GitHub Check: visual-diff snapshot (2/2)
  • GitHub Check: build
  • GitHub Check: test lib/es module (es, 1/2)
  • GitHub Check: test lib/es module (es, 2/2)
  • GitHub Check: test-react-latest (dom, 2/2)
  • GitHub Check: test-react-latest (dom, 1/2)
  • GitHub Check: test-react-legacy (17, 2/2)
  • GitHub Check: test-react-legacy (16, 1/2)
  • GitHub Check: test-react-legacy (16, 2/2)
  • GitHub Check: test-react-legacy (17, 1/2)
  • GitHub Check: build
  • GitHub Check: build preview
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2025

Preview is ready

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2025

👁 Visual Regression Report for PR #53994 Passed ✅

🎯 Target branch: master (50b9154)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎

🎊 Congrats! No visual-regression diff found.

afc163
afc163 previously approved these changes Jun 3, 2025
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 3, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2025

size-limit report 📦

Path Size
dist/antd.min.js 450.28 KB (+9 B 🔺)
dist/antd-with-locales.min.js 537.6 KB (+12 B 🔺)

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 3, 2025

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2025

Bundle Report

Changes will increase total bundle size by 86 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antd.min-array-push 3.39MB 86 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: antd.min-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antd-with-locales.min.js 43 bytes 1.85MB 0.0%
antd.min.js 43 bytes 1.54MB 0.0%

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jun 3, 2025

Deploying ant-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8b0eee8
Status: ✅  Deploy successful!
Preview URL: https://6abce220.ant-design.pages.dev
Branch Preview URL: https://fix-hooks.ant-design.pages.dev

View logs

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (50b9154) to head (8b0eee8).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #53994   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          774       774           
  Lines        14021     14023    +2     
  Branches      3712      3713    +1     
=========================================
+ Hits         14021     14023    +2     

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

@zombieJ
Copy link
Copy Markdown
Member Author

zombieJ commented Jun 3, 2025

test env 居然顺序和 client 不一样……蛋疼

@zombieJ zombieJ merged commit 8abb52f into master Jun 4, 2025
47 checks passed
@zombieJ zombieJ deleted the fix-hooks branch June 4, 2025 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HookModal update via fucntion does not work

3 participants