Skip to content

Conversation

edokeh
Copy link
Contributor

@edokeh edokeh commented Oct 13, 2025

Summary by CodeRabbit

  • 新功能
    • 数字键盘支持传入带标题的自定义按键对象或对象/字符串混合数组;新增 visible、title、showCloseButton、randomOrder、safeArea 及 onInput/onDelete/onConfirm/onClose 等配置与回调。
  • 文档
    • 更新中/英文文档,完善公开属性说明与示例,说明自定义按键对象与 title 用法;为虚拟输入补充 cursor 属性说明(movable/onMove)。
  • 测试
    • 新增自定义按键(含标题)渲染与输入回调测试用例。
  • 示例
    • 调整虚拟输入示例,使用带标题的小数点键并更新示例标题为“两位小数的金额输入”。

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 13, 2025
Copy link
Contributor

github-actions bot commented Oct 13, 2025

Preview is ready

Copy link

coderabbitai bot commented Oct 13, 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

Walkthrough

将 NumberKeyboard 的 customKey 类型从字符串/二元组扩展为支持对象或对象/字符串数组;组件内部规范化为 realKey/title 并据此渲染与触发回调;同步更新文档、示例与测试,并在文档中列出若干新增公开 props(仅文档与类型扩展,无运行时控制流大幅变更)。

Changes

Cohort / File(s) Change Summary
组件实现
src/components/number-keyboard/number-keyboard.tsx
引入 CustomKeyType = string | { key: string; title: string };将 NumberKeyboardProps.customKey 扩展为 CustomKeyType | CustomKeyType[];渲染与事件逻辑统一为 realKey,title/aria 基于对象字段,按键事件传递 realKey,回退键检测与处理相应更新。
文档(中文)
src/components/number-keyboard/index.zh.md
更新公开 API 文档:customKey 类型扩展为支持对象/数组形式;列出新增公开 props:onClose, onConfirm, onDelete, onInput, randomOrder, safeArea, showCloseButton, title, visible
文档(英文)
src/components/number-keyboard/index.en.md
同步更新 customKey 的类型描述为 string | { key: string; title: string } | (string | { key: string; title: string })[]
测试
src/components/number-keyboard/tests/number-keyboard.test.tsx
新增测试 “render with customKey and title”:使用 ['-', { key: '.', title: '小数点' }] 验证按键渲染、title 显示与点击触发 onInput 并传递对应值。
示例
src/components/virtual-input/demos/demo1.tsx
customKey='.' 替换为 { key: '.', title: '小数点' }(两处);更新两个 DemoBlock 标题为 “两位小数的金额输入”。
文档(VirtualInput)
src/components/virtual-input/index.en.md
文档中新增 cursor prop 描述(movable?: boolean, onMove?: (position: number) => void),仅文档更新。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as 用户
  participant NK as NumberKeyboard
  participant App as 上层回调

  rect rgb(250,252,255)
    note right of NK: 支持 string 或 {key,title},也支持数组
    U->>NK: 点击按键 (string 或 {key,title})
    NK->>NK: 规范化为 realKey / title
    alt 数字或自定义输入
      NK-->>App: onInput(realKey)
    else 删除键
      NK-->>App: onDelete()
    else 确认键
      NK-->>App: onConfirm()
    else 关闭键
      NK-->>App: onClose()
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

size:L

Suggested reviewers

  • afc163
  • zombieJ

Poem

我是小兔在键间跳,realKey 名字轻轻报,
小数点披上新外衣,按下去回调就报到,
退格轻敲风也笑,演示与测试都到位,
胡萝卜在旁默默等,键盘更聪明我开心 🥕

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 该标题准确突出本次 PR 的核心改动:数字键盘的 customKey 支持单独定制 title 以提升无障碍读屏体验,表述清晰且无冗余内容,能够让同事快速了解主要功能新增点。
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 0e86eb0 and c101b2d.

📒 Files selected for processing (1)
  • src/components/number-keyboard/number-keyboard.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/number-keyboard/number-keyboard.tsx
⏰ 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). (4)
  • GitHub Check: size
  • GitHub Check: compressed-size
  • GitHub Check: build preview
  • GitHub Check: check

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.

Copy link

Summary of Changes

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

此拉取请求的主要目的是增强数字键盘组件的无障碍功能。通过允许开发者为自定义按键提供一个明确的 title 属性,屏幕阅读器可以更准确地描述这些按键,从而显著改善使用辅助技术的用户的体验。这一改动涉及核心组件逻辑、类型定义、文档和测试的全面更新。

Highlights

  • 自定义按键无障碍支持: 数字键盘的 customKey 属性现在支持传入一个对象 { key: string; title: string },允许为自定义按键单独设置 title 属性,以提升无障碍读屏体验。
  • 类型定义更新: 更新了 NumberKeyboardPropscustomKey 属性的类型定义,使其能够接受字符串、字符串数组或包含 keytitle 的对象数组。
  • 测试与文档完善: 新增了测试用例以验证 customKey 新的对象格式功能,并更新了中文文档和示例代码,以反映这一变化。
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.

@coderabbitai coderabbitai bot requested a review from zombieJ October 13, 2025 07:29
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 为 NumberKeyboardcustomKey 属性增加了单独定制 title 的功能,这对于无障碍读屏非常有用,做得很好。代码实现基本正确,但我发现一个在处理数字类型的自定义按键时可能存在的 bug,另外文档中有一个小的格式问题。请查看我的具体评论。

Copy link

pkg-pr-new bot commented Oct 13, 2025

npm i https://pkg.pr.new/ant-design/ant-design-mobile/antd-mobile@6956

commit: c101b2d

@dosubot dosubot bot added the feature label Oct 13, 2025
@coderabbitai coderabbitai bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 13, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. size:L This PR changes 100-499 lines, ignoring generated files. labels Oct 13, 2025
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: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 489d444 and 331a1c1.

📒 Files selected for processing (4)
  • src/components/number-keyboard/index.zh.md (1 hunks)
  • src/components/number-keyboard/number-keyboard.tsx (4 hunks)
  • src/components/number-keyboard/tests/number-keyboard.test.tsx (1 hunks)
  • src/components/virtual-input/demos/demo1.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/components/virtual-input/demos/demo1.tsx (1)
src/components/number-keyboard/number-keyboard.tsx (1)
  • NumberKeyboard (52-279)
⏰ 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). (4)
  • GitHub Check: compressed-size
  • GitHub Check: build preview
  • GitHub Check: check
  • GitHub Check: size
🔇 Additional comments (6)
src/components/number-keyboard/number-keyboard.tsx (3)

15-21: 类型定义清晰,但需要注意向后兼容性。

新的 CustomKeyType 类型定义很好地支持了字符串和对象两种形式。但需要注意,原来支持的 [string, string] 元组形式已被移除,这是一个破坏性变更。建议:

  1. 在文档中添加迁移指南
  2. 或者考虑保留对元组形式的兼容支持

请确认是否需要保留对旧 API [string, string] 的向后兼容,或者在文档中明确说明这是破坏性变更。


180-184: LGTM!

title 属性的逻辑正确:

  • 删除键使用国际化文本
  • 对象形式使用自定义 title
  • 字符串形式使用 key 本身

这确保了屏幕阅读器能获取正确的无障碍信息。


203-207: LGTM!

事件处理和显示逻辑正确:

  • onKeyPress 使用 realKey 确保回调接收到实际的按键值
  • 显示内容使用 realKey 保持按键的实际字符

这保证了即使使用自定义 title,onInput 回调仍能接收到正确的按键值。

src/components/virtual-input/demos/demo1.tsx (2)

16-21: LGTM!

示例代码正确展示了新的对象形式 API,{ key: '.', title: '小数点' } 为小数点按键提供了清晰的无障碍标签,有助于屏幕阅读器用户理解按键功能。

Also applies to: 79-84


65-65: LGTM!

Demo 标题更新为"两位小数的金额输入"更准确地描述了该示例的功能约束。

src/components/number-keyboard/tests/number-keyboard.test.tsx (1)

164-184: LGTM!

测试用例全面验证了新功能:

  • 混合使用字符串和对象形式的 customKey
  • 验证 title 属性正确设置(字符串使用自身,对象使用 title 字段)
  • 确认 onInput 回调接收到正确的按键值('.' 而非 '小数点')

测试覆盖充分,确保了新 API 的正确性。

Copy link

codecov bot commented Oct 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.94%. Comparing base (489d444) to head (c101b2d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6956      +/-   ##
==========================================
- Coverage   92.95%   92.94%   -0.02%     
==========================================
  Files         337      337              
  Lines        7352     7354       +2     
  Branches     1829     1830       +1     
==========================================
+ Hits         6834     6835       +1     
- Misses        510      511       +1     
  Partials        8        8              

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

@coderabbitai coderabbitai bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Oct 13, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. size:XL This PR changes 500-999 lines, ignoring generated files. labels Oct 13, 2025
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/number-keyboard/number-keyboard.tsx (1)

170-175: 修正符号类名判断逻辑
在 src/components/number-keyboard/number-keyboard.tsx 第 172 行,将条件从 !isNumberKey && key 修改为 !isNumberKey && realKey

-      [`${classPrefix}-key-sign`]: !isNumberKey && key,
+      [`${classPrefix}-key-sign`]: !isNumberKey && realKey,
♻️ Duplicate comments (2)
src/components/number-keyboard/number-keyboard.tsx (1)

166-169: 关键逻辑修复正确。

已正确修复 isNumberKey 的判断逻辑,现在基于 realKey 进行判断,无论 key 是字符串还是对象形式都能正确识别数字按键。

src/components/number-keyboard/index.zh.md (1)

26-26: 修复 Markdown 表格格式错误。

表格分隔行有 7 列,但表头只有 4 列(属性、说明、类型、默认值),这会导致表格渲染异常。

应用此修复:

-| --- | --- | --- | --- | --- | --- | --- |
+| --- | --- | --- | --- |
🧹 Nitpick comments (1)
src/components/number-keyboard/index.zh.md (1)

31-31: 类型文档准确但可以更清晰。

customKey 的类型定义已更新为完整的联合类型,涵盖了字符串、对象和数组形式。为了帮助开发者更好理解,建议在"说明"列补充简短的使用示例。

可选的改进方案:

-| customKey | 自定义按钮 | `string | { key: string; title: string } | (string | { key: string; title: string })[]` | - |
+| customKey | 自定义按钮,支持单个或多个按键,可为字符串或包含 title 的对象(用于无障碍读屏) | `string \| { key: string; title: string } \| (string \| { key: string; title: string })[]` | - |

或者在下方添加使用示例说明不同形式的用法。

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 331a1c1 and 8a215b1.

📒 Files selected for processing (2)
  • src/components/number-keyboard/index.zh.md (1 hunks)
  • src/components/number-keyboard/number-keyboard.tsx (4 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). (3)
  • GitHub Check: compressed-size
  • GitHub Check: size
  • GitHub Check: check
🔇 Additional comments (3)
src/components/number-keyboard/number-keyboard.tsx (3)

15-15: 类型定义清晰准确。

新增的 CustomKeyType 类型定义支持字符串或包含 keytitle 的对象形式,很好地满足了无障碍读屏的需求。


180-184: Aria 属性处理正确。

title 属性的处理逻辑正确:

  • 退格键显示清除文案
  • 对象形式使用 title 字段供读屏软件朗读
  • 字符串形式直接使用 key

这很好地支持了无障碍访问需求。


203-207: 按键渲染和事件处理正确。

使用 realKey 进行事件传递和显示渲染是正确的设计:

  • 事件处理使用 realKey 确保输入值正确
  • 视觉显示使用 realKey 保持界面简洁
  • title 属性已在上方正确设置用于无障碍朗读

这种分离设计既满足了功能需求又兼顾了无障碍体验。

@coderabbitai coderabbitai bot requested a review from zombieJ October 13, 2025 09:52
@coderabbitai coderabbitai bot added lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files. labels Oct 13, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. size:L This PR changes 100-499 lines, ignoring generated files. labels Oct 13, 2025
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: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8a215b1 and a6a08ca.

📒 Files selected for processing (2)
  • src/components/number-keyboard/index.en.md (1 hunks)
  • src/components/number-keyboard/number-keyboard.tsx (4 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). (4)
  • GitHub Check: build preview
  • GitHub Check: check
  • GitHub Check: compressed-size
  • GitHub Check: size
🔇 Additional comments (1)
src/components/number-keyboard/number-keyboard.tsx (1)

167-170: LGTM! 已正确实现之前的审查建议。

keyConfig 规范化逻辑清晰,将字符串和对象形式统一处理。isNumberKey 的判断现在直接基于 realKey 进行正则测试,避免了之前的类型检查问题。

@coderabbitai coderabbitai bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 13, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. size:L This PR changes 100-499 lines, ignoring generated files. labels Oct 13, 2025
@coderabbitai coderabbitai bot requested a review from afc163 October 13, 2025 11:28
@coderabbitai coderabbitai bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 13, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. size:L This PR changes 100-499 lines, ignoring generated files. labels Oct 13, 2025
@coderabbitai coderabbitai bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 13, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. size:L This PR changes 100-499 lines, ignoring generated files. labels Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants