Tencent / Tencent/Hippy

[ohos] TextInput keyboardType="numeric" 映射为 InputType.Number,键盘无小数点,与 Android 端行为不一致

Open Beginner friendly
#4,589 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
8.6k
Forks
1k
Avg merge
1h 31m
Merged PRs (30d)
3

Description

期望结果

ohos 端 keyboardType="numeric" 应弹出带小数点的数字键盘,与 Android 端语义对齐(Android: TYPE_CLASS_NUMBER | TYPE_NUMBER_FLAG_DECIMAL | TYPE_NUMBER_FLAG_SIGNED);或至少提供带小数点数字键盘(ArkUI InputType.NUMBER_DECIMAL)的映射,否则金额类输入在 ohos 端无法输入小数。

实际结果

ohos 端 numeric 被映射为 ArkUI InputType.Number(纯数字键盘),键盘上没有小数点按键,价格输入框无法输入小数点

重现链接

No response

重现步骤

结合源码和arkts官方文档得出结论确实有问题
Image

Image Image
重现环境
  • Device: HarmonyOS NEXT Mate70
  • OS and Version: HarmonyOS NEXT 7.0.0
  • Hippy SDK Version: hippy ohos 3.3.8(ohpm);@hippy/vue 3.3.2
  • DevEco Studio: DevEco Studio 6.1.1
补充说明

业务场景:价格编辑(金额输入),必须支持小数。

修复建议:在 HRTextInputView.ets 的 setKeyBoardType() 中将 numeric 映射为 ArkUI 的
InputType.NUMBER_DECIMAL(API 11+ 起提供,带小数点的数字键盘,声明见
ets/component/text_input.d.ts InputType.NUMBER_DECIMAL = 12),与 Android 端的
DECIMAL 语义对齐,前端无需任何改动;或新增独立的 "decimal" 键盘映射供业务按需选择。

临时规避:前端改用默认键盘(有字母,体验差)或业务层 inputFilter 校验,均不理想,
希望在框架层对齐三端行为。

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open ohos HRTextInputView.ets and start with setKeyBoardType(), checking how numeric is mapped to ArkUI InputType. Compare the mapping with the Android numeric behavior and the ArkUI InputType.NUMBER_DECIMAL documentation. Done means ohos numeric inputs show a decimal key and support decimal price entry without frontend changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
android
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.