Skip to content

Conversation

EmilyyyLiu
Copy link
Contributor

@EmilyyyLiu EmilyyyLiu commented Aug 12, 2025

mask可配置为blur

Summary by CodeRabbit

  • 新功能
    • Dialog 新增 mask="blur" 选项,支持背景模糊遮罩;默认行为不变。
  • 文档
    • 更新 API 说明:mask 支持 boolean | 'blur',并新增 onClose、afterClose、getContainer、destroyOnHidden、closeIcon、forceRender、focusTriggerAfterClose、modalRender 等属性说明(含版本标注与签名);修剪多余空行与尾随空格。
  • 样式
    • 为遮罩新增模糊样式类并整理淡入过渡选择器格式(无功能变更)。
  • 测试
    • 新增 mask="blur" 渲染与样式类断言用例,提升覆盖。

Copy link

vercel bot commented Aug 12, 2025

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

Project Deployment Preview Comments Updated (UTC)
dialog Ready Preview 💬 Add feedback Aug 12, 2025 9:22am

Copy link

coderabbitai bot commented Aug 12, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

本次变更为 Dialog 新增 mask 可取字符串值 'blur':类型、组件与文档同步更新;样式加入对应模糊遮罩规则;入口透传 mask;新增针对 blur 的测试用例;并做了若干 README 格式修整。

Changes

Cohort / File(s) Change Summary
Dialog 类型与组件
src/IDialogPropTypes.tsx, src/Dialog/Mask.tsx, src/Dialog/index.tsx
mask 类型从 boolean 扩展为 `boolean
样式:模糊遮罩
assets/index/Mask.less
新增 &&-blur 规则,使用 backdrop-filter: blur(4px);;调整两处过渡选择器为多行列举(仅格式化)。
文档
README.md
更新 API 表:mask 描述改为 `Boolean
测试
tests/index.spec.tsx
新增用例 "Dialog mask blur":渲染 mask="blur"visible,断言根元素及 rc-dialog-mask-blur 存在。

Sequence Diagram(s)

sequenceDiagram
  participant App as 调用方
  participant Dialog as Dialog
  participant Mask as Mask
  participant DOM as DOM/CSS

  App->>Dialog: 渲染 { mask: true | 'blur', visible }
  Dialog->>Mask: 透传 mask
  Mask->>DOM: 渲染遮罩并根据 mask 添加类名(-mask-blur)
  DOM->>DOM: 应用 CSS backdrop-filter: blur(4px)(当类名存在)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • zombieJ

Poem

小兔轻踩键与笔,
一句 "blur" 绕云帘;
遮罩轻柔如雾染,
测试一过安心眠。
咔嚓代码跳舞间,
版本里藏春日田。

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @EmilyyyLiu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求引入了一项新功能,允许对话框遮罩具有模糊效果。通过为mask属性添加新的blur选项并应用backdrop-filter: blur CSS属性来实现。

Highlights

  • 新的mask属性选项: Dialog组件的mask属性现在除了接受boolean类型外,还接受'blur'值。
  • 模糊效果的CSS: 添加了一个新的CSS类*-mask-blur,当mask属性设置为'blur'时,该类将为遮罩应用backdrop-filter: blur(4px)效果。
  • 集成: Mask组件现在会检查mask === 'blur'条件,以有条件地应用新的模糊类。
  • 文档更新: README.md已更新,以反映新的mask属性类型。
  • 测试用例: 添加了一个新的测试用例Dialog mask blur来验证此功能。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

codecov bot commented Aug 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.46%. Comparing base (acf2569) to head (1719877).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #507   +/-   ##
=======================================
  Coverage   98.46%   98.46%           
=======================================
  Files           8        8           
  Lines         195      196    +1     
  Branches       68       69    +1     
=======================================
+ Hits          192      193    +1     
  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.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这个 PR 为对话框的遮罩层增加了一个很棒的 'blur' 选项。实现方式很直接,也包含了新的测试用例。我提出了一些建议,主要是为了提高模糊效果的浏览器兼容性,以及更新文档使其更清晰。

z-index: 1050;

&&-blur {
backdrop-filter: blur(4px);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了更好的浏览器兼容性,特别是对于旧版本的 Safari,建议为 backdrop-filter 属性添加 -webkit- 前缀。

      -webkit-backdrop-filter: blur(4px);
      backdrop-filter: blur(4px);

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 (5)
README.md (1)

68-68: 补充 mask='blur' 的语义描述,提升可读性

当前描述仍是 “whether show mask”,未体现 'blur' 的效果。建议在表格里直接说明传入 'blur' 将展示带模糊效果的遮罩,便于用户理解与检索。

应用如下变更以明确语义:

-| mask | Boolean \| `blur` | true | whether show mask |  |
+| mask | Boolean \| `blur` | true | 控制是否展示遮罩;传入 `blur` 时为带背景模糊的遮罩 |  |
assets/index/Mask.less (1)

13-15: 为 Safari 兼容性补充 -webkit-backdrop-filter 前缀

backdrop-filter 在 Safari 需加上 -webkit-backdrop-filter 才能生效。建议同时声明以提升跨浏览器一致性。

参考改动:

     &&-blur {
       backdrop-filter: blur(4px);
+      -webkit-backdrop-filter: blur(4px);
     }
src/Dialog/Mask.tsx (1)

16-16: 避免 maskProps.className 覆盖内部类名,建议显式合并

目前 {...maskProps} 在 className 之后展开,若 maskProps 里带 className 会覆盖 ${prefixCls}-mask-mask-blur,导致样式失效。建议拆出并合并 maskProps.className,其余属性再展开。

可按以下方式调整:

-  const { prefixCls, style, visible, maskProps, motionName, className, mask } = props;
+  const { prefixCls, style, visible, maskProps, motionName, className, mask } = props;
+  const { className: maskPropsClassName, ...restMaskProps } = maskProps || {};

@@
-          className={classNames(
-            `${prefixCls}-mask`,
-            motionClassName,
-            className,
-            mask === 'blur' && `${prefixCls}-mask-blur`,
-          )}
-          {...maskProps}
+          className={classNames(
+            `${prefixCls}-mask`,
+            motionClassName,
+            className,
+            maskPropsClassName,
+            mask === 'blur' && `${prefixCls}-mask-blur`,
+          )}
+          {...restMaskProps}

Also applies to: 28-34

src/IDialogPropTypes.tsx (1)

28-29: 为 mask 字段补充注释,增强 IDE 悬浮提示与文档可读性

明确 'blur' 的行为能减少误用。

建议在类型上方添加注释:

-  mask?: boolean | 'blur';
+  /** true 显示遮罩;false 不显示;`'blur'` 显示并对背景应用模糊效果 */
+  mask?: boolean | 'blur';
tests/index.spec.tsx (1)

756-761: 增强断言:同时校验基础遮罩类与 blur 类在同一元素上,且仅渲染一个遮罩

为防止未来实现回归(例如新增独立 blur 元素或丢失基础类),建议在同一测试中校验:

  • 基础遮罩元素 .rc-dialog-mask 存在;
  • 该元素包含 .rc-dialog-mask-blur 类;
  • 遮罩只渲染一个实例。

可在当前用例中追加如下断言:

 it('Dialog mask blur', () => {
   render(<Dialog mask="blur" visible/>);
   jest.runAllTimers();
   expect(document.querySelector('.rc-dialog-root')).toBeTruthy();
-  expect(document.querySelector('.rc-dialog-mask-blur')).toBeTruthy();
+  expect(document.querySelector('.rc-dialog-mask-blur')).toBeTruthy();
+  // 基础遮罩元素仍存在
+  const maskEl = document.querySelector('.rc-dialog-mask');
+  expect(maskEl).toBeTruthy();
+  // blur 类应附加在同一个遮罩元素上
+  expect((maskEl as HTMLElement).className).toContain('rc-dialog-mask-blur');
+  // 不应渲染重复的遮罩
+  expect(document.querySelectorAll('.rc-dialog-mask')).toHaveLength(1);
 });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between acf2569 and 5405d97.

📒 Files selected for processing (6)
  • README.md (2 hunks)
  • assets/index/Mask.less (3 hunks)
  • src/Dialog/Mask.tsx (2 hunks)
  • src/Dialog/index.tsx (1 hunks)
  • src/IDialogPropTypes.tsx (2 hunks)
  • tests/index.spec.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (6)
README.md (1)

107-107: Contributing 标题与排版调整:LGTM

文档结构更清晰,无功能性影响。

assets/index/Mask.less (1)

27-29: 选择器换行与格式化:LGTM

将多个选择器分行更利于维护与 diff 对比,无语义变化。

Also applies to: 39-41

src/Dialog/Mask.tsx (1)

12-12: MaskProps 扩展 mask?: boolean | 'blur':LGTM

类型与新增能力对齐,兼容已有用法。

src/IDialogPropTypes.tsx (1)

4-11: SemanticName 多行格式化:LGTM

仅格式调整,无行为变化。

src/Dialog/index.tsx (1)

201-201: 向 Mask 组件透传 mask:LGTM

与新能力对齐;同时 visible={mask && visible}mask === 'blur' 时会返回 visible 的布尔值,类型与语义均正确。

tests/index.spec.tsx (1)

755-761: 新增用例方向正确,能验证 blur 掩膜类名注入

此用例覆盖了 mask="blur" 的渲染路径,并断言了 rc-dialog-mask-blur 的存在,基本正确。

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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 (1)
README.md (1)

68-68: 类型标注与描述措辞微调建议

  • Type 列建议使用 Boolean | 'blur',与代码实现 mask?: boolean | 'blur' 保持一致。
  • 描述中的 “Can be set to …” 是句子残片,建议合并为一句,避免语法瑕疵(LanguageTool 提示)。

建议按下方 diff 修改该行(仅文案与类型表示调整):

-| mask | Boolean \| `blur` | true | whether to show the mask. Can be set to `blur` for a blur effect. |  |
+| mask | Boolean \| 'blur' | true | whether to show the mask; set to 'blur' for a blur effect. |  |

另外,请确认是否需要在 Version 列标注该能力的首次支持版本,便于用户识别变更所属版本。需要的话我可以一并补充。

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5405d97 and 1719877.

📒 Files selected for processing (1)
  • README.md (2 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[style] ~68-~68: To form a complete sentence, be sure to include a subject.
Context: ...lur| true | whether to show the mask. Can be set toblur` for a blur effect. | ...

(MISSING_IT_THERE)

🔇 Additional comments (1)
README.md (1)

107-107: 文档结构优化已确认

移除多余空行并规范化 “Contributing” 小节标题,排版更整洁,无需进一步改动。

| footer | React.Element | | footer of the dialog | |
| closable | Boolean \| ({ closeIcon?: React.ReactNode; disabled?: boolean, afterClose:function } & React.AriaAttributes) | true | whether show close button | |
| mask | Boolean | true | whether show mask | |
| mask | Boolean \| `blur` | true | whether to show the mask. Can be set to `blur` for a blur effect. | |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得做到 next 里,然后ConfigProvider 支持一个 mask 的 className 和 style 会比较好。然后做一个语法糖:

<ConfigProvider mask={{ blur: false }} />

@EmilyyyLiu EmilyyyLiu closed this Aug 12, 2025
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