Skip to content

同步 master 分支的一些 bugfix 到 antd-v5 分支,以修复 antd@v5 的 bug #371

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 2 commits into from
Apr 16, 2025

Conversation

Wxh16144
Copy link
Contributor

@Wxh16144 Wxh16144 commented Apr 16, 2025

  1. 注意不要 squash merge

Summary by CodeRabbit

  • 新功能

    • 支持通过 closable 属性对象自定义关闭按钮图标,并可传递无障碍属性(aria 属性)到关闭按钮。
  • 样式

    • 优化关闭按钮样式,去除边框并设置为白色背景。
  • 测试

    • 增加了对动态修改通知持续时间和关闭按钮无障碍属性的测试用例。
    • 调整自定义关闭图标的测试方式,适配新的 closable 属性结构。

yellowryan and others added 2 commits April 16, 2025 14:09
…eact-component#365)

* fix: some properties changed by useState are not work

* test: add test

(cherry picked from commit d315300)
* revert solution

* fix again

(cherry picked from commit 3b1e34b)
Copy link

vercel bot commented Apr 16, 2025

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

Name Status Preview Comments Updated (UTC)
notification ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 16, 2025 6:26am

Copy link

coderabbitai bot commented Apr 16, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

此次更改主要涉及通知组件的关闭按钮和相关接口。样式上,关闭按钮的 CSS 被调整,移除了边框并设置了白色背景。组件实现上,关闭按钮从 <a> 元素改为 <button>,事件处理和 aria 属性传递方式也做了相应调整。接口层面,closeIcon 属性被整合进 closable,支持通过对象传递自定义关闭图标及无障碍属性。测试用例同步更新,验证新接口和动态属性更新的有效性。同时,useNotification 钩子内部对 open 方法进行了结构性重构,提升了事件处理的稳定性。

Changes

文件/分组 变更摘要
assets/index.less .rc-notification-notice-close 样式新增 border: 0;background-color: #fff;
src/Notice.tsx 关闭按钮由 <a> 改为 <button>,事件处理和 aria 属性传递方式调整,关闭图标渲染逻辑重构。
src/interface.ts NoticeConfig 接口移除 closeIconclosable 支持对象形式并可携带 closeIcon 和 aria 属性。
src/hooks/useNotification.tsx open 方法提取为 useEvent 回调,api 对象使用 useMemo,结构性优化,无功能变更。
tests/index.test.tsx 测试用例同步新接口,新增动态 duration 测试与 aria 属性传递测试。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant NotificationAPI
    participant NotificationComponent

    User->>NotificationAPI: open({ closable: { closeIcon, ...ariaProps } })
    NotificationAPI->>NotificationComponent: 渲染通知,传递 closable 对象
    NotificationComponent->>NotificationComponent: 渲染 close button,应用 closeIcon 和 aria 属性
    User->>NotificationComponent: 点击 close button
    NotificationComponent->>NotificationAPI: 触发关闭逻辑
Loading

Possibly related PRs

  • react-component/notification#365: 该 PR 也涉及 useNotificationopen 方法内部实现的重构,关注点为配置对象的 memo 化,与本次 PR 的重构方向相关。
  • react-component/notification#366: 该 PR 同样重构了 useNotificationopen 方法,采用 useEvent,与本次 PR 的实现方式直接相关。

Poem

小兔挥笔写通知,
关闭按钮变按钮,样式焕新颜。
closeIcon 藏进 closable,
aria 属性也能传。
钩子重构更稳定,
测试验证真周全。
咔嚓一声,通知再见!
🐰✨


🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

@Wxh16144 Wxh16144 changed the base branch from master to antd-5.x April 16, 2025 06:17
@Wxh16144

This comment was marked as outdated.

Copy link

codecov bot commented Apr 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.74%. Comparing base (f4c10c1) to head (68aedc6).
Report is 1 commits behind head on antd-5.x.

Additional details and impacted files
@@            Coverage Diff            @@
##           antd-5.x     #371   +/-   ##
=========================================
  Coverage     99.74%   99.74%           
=========================================
  Files             7        7           
  Lines           773      777    +4     
  Branches        125      125           
=========================================
+ Hits            771      775    +4     
  Misses            2        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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@afc163 afc163 merged commit 00dc849 into react-component:antd-5.x Apr 16, 2025
9 checks passed
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