Skip to content

Conversation

@aojunhao123
Copy link
Contributor

@aojunhao123 aojunhao123 commented Dec 18, 2025

Summary by CodeRabbit

发布说明

  • 改进

    • 改进了组件的可访问性支持,添加了方向指示属性。
  • 依赖更新

    • 升级测试库依赖至最新版本。

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 18, 2025

概览

此 PR 包含配置更新、依赖升级和可访问性属性调整。在 .dumirc.ts 中添加了模块别名映射,将 @testing-library/jest-dom 依赖版本从 5.16.5 升级至 6.9.1,修改了 src/index.tsx 中的 ARIA 属性(移除了标签上的 rolearia-checked,在容器上添加了 aria-orientation),以及更新了 tsconfig.json 的类型定义和包含路径。

变更

类别 / 文件 变更摘要
配置更新
.dumirc.ts, tsconfig.json, package.json
新增模块别名 rc-segmented 指向 src/index.tsx@testing-library/jest-dom 依赖升级至 v6.9.1;TypeScript 编译器选项中添加类型定义并将 include 路径从 docs/examples 改为 docs/demo
可访问性属性调整
src/index.tsx
移除分段选项标签上的 role="radio"aria-checked 属性;在分段容器外层 div 上添加 aria-orientation 属性以反映垂直或水平方向

估计代码审查工作量

🎯 2 (简单) | ⏱️ ~10 分钟

  • 依赖版本升级可能引入破坏性变更,需检查 @testing-library/jest-dom v6.x 的迁移指南
  • 可访问性属性变更涉及 ARIA 规范,建议验证对屏幕阅读器的影响

相关 PR

建议审查人

  • afc163

诗歌

🐰 配置优化笔一挥,
别名映射巧安排,
ARIA 属性显真心,
无障碍之路更宽阔。

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确反映了主要变更:移除重复的 radio 角色并优化 ARIA 属性,与实际代码变更(从标签元素中删除 role 和 aria-checked,添加 aria-orientation)相符。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @aojunhao123, 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!

This pull request focuses on refining the accessibility of the segmented control component by optimizing its ARIA attributes. It addresses a potential redundancy in ARIA roles and states on individual segmented items and enhances the overall accessibility by explicitly defining the orientation of the segmented control group. Additionally, it includes minor updates to development dependencies and configuration files to support these changes and improve the development environment.

Highlights

  • Accessibility Optimization: Removed redundant role="radio" and aria-checked attributes from the segmented item labels, as these are already handled by the native radio input, improving screen reader experience.
  • Enhanced Accessibility: Added the aria-orientation attribute to the main radiogroup element, explicitly defining whether the segmented control is vertical or horizontal for better assistive technology support.
  • Dependency Update: Updated the @testing-library/jest-dom development dependency to its latest version.
  • Development Configuration: Introduced a path alias for rc-segmented in .dumirc.ts to point to the local source, streamlining local development and documentation builds. Also updated tsconfig.json to include @testing-library/jest-dom types and adjusted a documentation path.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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

@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​testing-library/​jest-dom@​5.17.0 ⏵ 6.9.110010010089100

View full report

@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.39%. Comparing base (6fc03b2) to head (4ceb3b4).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #317   +/-   ##
=======================================
  Coverage   99.39%   99.39%           
=======================================
  Files           2        2           
  Lines         164      165    +1     
  Branches       39       41    +2     
=======================================
+ Hits          163      164    +1     
  Misses          1        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
Contributor

@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

This pull request introduces several valuable improvements. The core changes enhance the accessibility of the Segmented component by removing a redundant role="radio" attribute and adding the aria-orientation attribute to the radiogroup. These changes align the component with WAI-ARIA best practices, providing a better experience for users of assistive technologies. Additionally, the PR includes dependency updates, configuration file corrections, and snapshot updates, all of which contribute to the overall health and maintainability of the codebase. The changes are correct and well-implemented.

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

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6fc03b2 and 4ceb3b4.

⛔ Files ignored due to path filters (1)
  • tests/__snapshots__/index.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (4)
  • .dumirc.ts (1 hunks)
  • package.json (1 hunks)
  • src/index.tsx (1 hunks)
  • tsconfig.json (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: preview
🔇 Additional comments (4)
tsconfig.json (2)

15-15: 代码变更看起来不错!

@testing-library/jest-dom 添加到 types 数组与 package.json 中的版本升级保持一致,这确保 TypeScript 能够识别 jest-dom 提供的自定义匹配器。


22-22: docs/demo 目录已正确迁移

验证确认 docs/demo 目录存在且包含完整的演示文件(basic、controlled、custom-render、dynamic、html-title、name、refs、rtl),原有的 docs/examples 目录已被移除。tsconfig.json 中的 include 路径更新与实际目录结构一致。

src/index.tsx (1)

309-309: 优秀的无障碍改进!

在 radiogroup 容器上添加 aria-orientation 属性是正确的,它能向辅助技术明确传达控件的方向(水平或垂直)。

结合 AI 摘要中提到的更改(从 label 元素移除重复的 role="radio"aria-checked 属性),这些改进符合 ARIA 最佳实践:

  • 避免角色重复:label 包裹的 input[type="radio"] 已经具有隐式的 radio 角色
  • 正确的属性位置:aria-checked 应该在 input 元素上,而不是 label 上
  • 语义化容器属性:radiogroup 正确声明了其方向

这些更改提升了组件对屏幕阅读器等辅助技术的支持。

.dumirc.ts (1)

2-2: 代码变更看起来不错!

添加 path 模块导入和 alias 配置是正确的。alias 映射使得文档和演示能够直接引用本地源代码 src/index.tsx,这是 Dumi 组件库的常见开发模式,有助于在文档中测试实际源代码。

Also applies to: 17-19

"@rc-component/father-plugin": "^2.0.1",
"@rc-component/np": "^1.0.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/jest-dom": "^6.9.1",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

更新导入路径和测试设置配置以适配 v6 的破坏性变更

从 v5.16.5 升级到 v6.9.1 涉及多项破坏性变更需要处理:

  • v6.0.0 移除了 extend-expect 脚本,不能再直接在 setupFilesAfterEnv 中引用包名
  • TypeScript 类型定义加载机制已更改,需要创建独立的设置文件或使用明确的导入路径(如 @testing-library/jest-dom/jest@testing-library/jest-dom/jest-globals@testing-library/jest-dom/vitest
  • 需要验证项目的 Jest 配置和测试设置文件是否已相应调整
🤖 Prompt for AI Agents
In package.json around line 57, the dependency was updated to
"@testing-library/jest-dom": "^6.9.1" but v6 introduced breaking changes: remove
direct package name in setupFilesAfterEnv and adjust TypeScript/type loading.
Fix by creating/using an explicit test setup file (e.g., tests/setupTests.ts or
jest.setup.ts) that imports the correct v6 entry (one of
@testing-library/jest-dom/jest, @testing-library/jest-dom/jest-globals, or
@testing-library/jest-dom/vitest depending on test runner), update package.json
Jest configuration to reference that setup file in setupFilesAfterEnv (not the
package name), and ensure TypeScript config includes the setup file types or add
the appropriate types import so type definitions load correctly.

@afc163 afc163 merged commit 4461115 into react-component:master Dec 18, 2025
8 checks passed
@aojunhao123
Copy link
Contributor Author

@afc163 佬,这个需要cheery-pick到v5吗

@afc163
Copy link
Member

afc163 commented Dec 18, 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