Skip to content

fix: support data attributes in closable - #591

Merged
yoyo837 merged 1 commit into
react-component:masterfrom
QDyanbing:fix-closable-data-attrs
Nov 20, 2026
Merged

yoyo837 merged 1 commit into
react-component:masterfrom
QDyanbing:fix-closable-data-attrs

Conversation

@QDyanbing

@QDyanbing QDyanbing commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Dialog 的 closable 对象目前既未声明 data-,也未将其透传到关闭按钮。本次补充 data- 索引类型,并使用 pickAttrs 的 { aria: true, data: true } 配置提取按钮属性。

通过 Dialog 公开入口验证 data-testid、数值型 data-*、aria-label 和 role,确认 disabled 时按钮仍显示且禁用,关闭点击仍调用原有回调,普通 DOM 属性和额外事件不会被透传。保留图标、遮罩关闭、Esc、退出动画及回调行为。

验证:

  • npm test -- --runInBand:60 项测试、4 个快照通过,1 项既有测试跳过。
  • npm run tsc、npm run lint,以及修改测试文件的 ESLint 检查通过;lint 存在既有警告。

本次仅补齐兼容性支持,不推进 V7 的 closable 行为统一。

参考:ant-design/ant-design#59667

Summary by CodeRabbit

  • 新功能
    • 关闭按钮现在支持自定义 aria-* 和 data-* 属性,包括数值型 data-* 属性,便于配置无障碍信息和自定义标识。
    • 自定义属性会应用于关闭按钮;标题和关闭图标仍不会作为按钮属性传入,独立的 onClick 也不会因此触发。

@vercel

vercel Bot commented Nov 20, 2026

Copy link
Copy Markdown

@QDyanbing is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

关闭按钮现在会透传 closable 中的 ARIA 和 data-* 属性。ClosableType 接受 data-* 键。测试覆盖自定义属性、按钮禁用状态及点击行为。

Changes

关闭按钮属性透传

Layer / File(s) Summary
属性声明、透传与测试
src/IDialogPropTypes.ts, src/Dialog/Content/Panel.tsx, tests/index.spec.tsx
ClosableType 新增 data-* 字符串索引签名。Panel 筛选并传递 ARIA 和 data-* 属性。测试覆盖自定义属性、禁用状态,以及 onClose 和 onClick 的调用行为。

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Feature

Suggested reviewers: kiner-tang, zombiej, divyeshagrawal

Merge Risk: Minimal · up to 2487b

This change lets the Dialog close button receive data-* and ARIA attributes from closable. Existing close behavior is intended to stay the same, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题 “fix: support data attributes in closable” 与变更内容一致。变更为 Dialog 的 closable 对象新增 data-* 属性支持:Panel.tsx 使用 pickAttrs 收集 aria 与 data 属性,IDialogPropTypes.ts 为 ClosableType 增加 data-${string} 索引签名,测试覆盖 dat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

标题 “fix: support data attributes in closable” 与变更内容一致。变更为 Dialog 的 closable 对象新增 data-* 属性支持:Panel.tsx 使用 pickAttrs 收集 aria 与 data 属性,IDialogPropTypes.ts 为 ClosableType 增加 data-${string} 索引签名,测试覆盖 data-testid、数值型 data-count、aria 与 role 等场景。标题简洁、具体,并指出主要变更。

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

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.

ESLint install timed out. The project may have too many dependencies for the sandbox.

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

我是小兔,带来一枚按钮标签。
aria-label 和 data-testid,都能跟上。
数数的 data-count,也安稳落下。
按钮禁用时,测试仍把它找到。
点击之后,关闭事件照常抵达。
我蹦回草丛,留下轻轻的代码声。

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 990b0515-b99b-4690-858e-4712fdf1aabf
Commits

Reviewing files that changed from the base of the PR and between 08eebe4 and 2487b8c.

Files selected for processing: 3

  • src/Dialog/Content/Panel.tsx
  • src/IDialogPropTypes.ts
  • tests/index.spec.tsx

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@codecov

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.95%. Comparing base (08eebe4) to head (2487b8c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #591   +/-   ##
=======================================
  Coverage   98.95%   98.95%           
=======================================
  Files           8        8           
  Lines         192      192           
  Branches       69       69           
=======================================
  Hits          190      190           
  Misses          2        2           

☔ View full report in Codecov by Harness.
📢 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.

@yoyo837
yoyo837 merged commit e2b50c3 into react-component:master Nov 20, 2026
11 of 12 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.

2 participants