Skip to content

fix: support Android IME mask input - #1005

Open
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/fix-android-ime-mask-input
Open

fix: support Android IME mask input#1005
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/fix-android-ime-mask-input

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 27, 2026

Copy link
Copy Markdown

Summary

  • recover masked input from the native input event when Android virtual keyboards report event.key as Unidentified
  • reuse the existing mask-cell formatting path for inserted text and forward/backward deletion
  • cover both single and range pickers with Android-style keydown/input sequences

Why

Masked picker input currently relies on keydown to identify numeric keys. Android IMEs such as Gboard and SwiftKey can report Unidentified, so the mask handler ignores the character even though the following native input event contains it.

The fallback is narrowly gated to an immediately preceding Unidentified keydown. Ordinary keyboard input continues through the existing keydown path, avoiding duplicate processing.

Fixes #929.

Validation

  • npm test -- --runInBand — 15/15 suites, 470 passed, 2 skipped, 29 snapshots
  • focused ESLint for the changed source and test files
  • Prettier check and git diff --check
  • npm run lint:tsc reaches only the existing deprecated Jest matcher type errors in tests/picker.spec.tsx; the exact base reproduces the same errors

AI assistance disclosure: Codex was used to trace the masked-input event flow, implement the fallback, and draft regression tests. I verified the failure on current master before the fix and ran the validation above on the submitted commit.

Summary by CodeRabbit

  • Bug Fixes

    • 改进 Android 虚拟键盘下的格式化输入处理,确保日期等掩码字段能够正确识别逐字符输入。
    • 修复 Android 输入法场景下日期选择器及日期范围选择器的输入和提交结果异常问题。
  • Tests

    • 新增 Android 输入法输入日期及日期范围的覆盖测试。

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@nrps9909 is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3e997d82-0995-4e6f-8064-b5c92fb4e444

📥 Commits

Reviewing files that changed from the base of the PR and between 16084b6 and 3764e05.

📒 Files selected for processing (2)
  • src/PickerInput/Selector/Input.tsx
  • tests/keyboard.spec.tsx

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


Walkthrough

变更概述

Input 组件支持 Android 虚拟键盘的 Unidentified 按键。组件改用原生 input 事件恢复字符和删除操作。新增 DayPicker 与 DayRangePicker 的掩码日期输入测试。

Changes

Android IME 掩码输入

Layer / File(s) Summary
提取格式化按键处理与状态管理
src/PickerInput/Selector/Input.tsx
组件将按键处理提取为 triggerFormatKey,并记录 Unidentified 按键状态。失焦时重置该状态。
接入原生输入事件并验证日期输入
src/PickerInput/Selector/Input.tsx, tests/keyboard.spec.tsx
组件根据 inputTypedata 处理字符、Backspace 与 Delete。测试覆盖 DayPickerDayRangePickerYYYYMMDD Android IME 输入。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 3764e

Android masked-input handling now accepts characters and deletion from native IME events while preserving the existing formatting and validation behavior. Regression coverage is included, and no actionable merge-blocking risk remains beyond normal checks.

Sequence Diagram(s)

sequenceDiagram
  participant AndroidIME
  participant Input
  participant triggerFormatKey
  participant Picker
  AndroidIME->>Input: 发送 keydown(Unidentified)
  Input->>Input: 设置 nativeInputRef
  AndroidIME->>Input: 发送 input(inputType, data)
  Input->>triggerFormatKey: 映射字符或删除操作
  triggerFormatKey->>Picker: 更新掩码输入
Loading

Suggested reviewers: zombiej, afc163

Poem

小兔敲键盘,Unidentified 不慌张
原生 input 带来数字光
掩码日期逐格排成行
DayPicker 收下新时光
RangePicker 两端都安康

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题明确说明了 PR 的主要变更:支持 Android IME 的掩码输入。
Linked Issues check ✅ Passed 代码处理 Android IME 上报的 Unidentified keydown,并通过原生 input 事件完成掩码格式化、插入和删除。测试覆盖 DatePickerRangePicker,符合 Issue #929 的核心目标。
Out of Scope Changes check ✅ Passed 变更仅涉及 Selector/Input.tsx 的 Android IME 输入处理,以及对应的键盘测试。未发现与 Issue #929 无关的代码变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 failed: private package registry requires authentication. Disable ESLint in CodeRabbit settings or use public packages.


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.

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.

Android IME keyboards not working with DatePicker/RangePicker due to keydown handling

1 participant