Input Number: Avoid Number Zero as First Character
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- react
- 领域
- frontend
调研方向
从链接的 StackBlitz 复现示例以及 InputNumber 组件的事件和受控值行为开始。跟踪第一个字符 0 在自定义 callback 运行前是如何被格式化的。完成的标准是:用户可以阻止初始的 0.00 出现,或可以在 UI 更新前可靠地控制该值,并且该行为有回归测试覆盖。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
I'm not sure whether this is the intended behavior or a bug, but I need to prevent users from inserting 0 as the first character when entering currency values. In this scenario, users should not be able to type or see 0.00 as the initial UI value.
Currently, I cannot find a way to intercept or override the component’s internal onChange behavior. It appears that the input triggers its own change handling regardless of any custom onChange logic I pass.
For example, in this StackBlitz demo: https://stackblitz.com/edit/1vp6gkfe?file=src%2FApp.jsx
the first input has no onChange handler, yet typing still updates the UI. This suggests the component always processes the input internally before (or instead of) delegating to the user-provided handler.
I also tried:
- Making the component fully controlled with
useState - Using
useRef+ manually attaching event listeners to the underlying
…but none of these approaches prevented the initial 0.00 from appearing.
Is there a recommended way to block the first character from being 0, or to fully control the formatting/validation before the UI updates?
Reproducer
https://stackblitz.com/edit/1vp6gkfe?file=src%2FApp.jsx
System Information
System:
OS: Linux 6.14 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat)
CPU: (16) x64 13th Gen Intel(R) Core(TM) i7-13620H
Memory: 46.15 GB / 62.54 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 22.21.1 - /home/rrs/.nvm/versions/node/v22.21.1/bin/node
npm: 10.9.4 - /home/rrs/.nvm/versions/node/v22.21.1/bin/npm
pnpm: 10.13.1 - /home/rrs/.nvm/versions/node/v22.21.1/bin/pnpm
Browsers:
Chrome: 142.0.7444.134
Firefox: 145.0
Firefox Developer Edition: 145.0
npmPackages:
primereact: ^10.9.0 => 10.9.1
react: 19.0.0 => 19.0.0
tailwindcss: ^3 => 3.4.16
Steps to reproduce the behavior
Type 0 as the first character.
Expected behavior
If users type 0 as the first character, UI shouldn't show it. It not necessary need to be character 0, I just need a way to trigger my own onChange or onValueChanged method.
- 主要语言
- CSS
- 星标
- 8.3k
- 派生
- 1.2k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
primefaces/primereact 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
primefaces/primereact#8552 ·
-
难度 1/5 1-3 小时 新手友好度 88/100
primefaces/primereact#8550 ·
-
Row checkbox selection tick is invisible in Landing Page Theme section可能已有人在做 @Prakash1185 于 150 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
primefaces/primereact#8545 ·
-
Dependency conflict between jspdf v4 and jspdf-autotable during npm install可能已有人在做 @Kamran92 于 164 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
primefaces/primereact#8537 ·
-
难度 3/5 1-2 天 新手友好度 58/100
primefaces/primereact#8551 ·
查看 primefaces/primereact 的全部 Issue
相似的 Issue
-
ai-driven-fuzzing bug claude Minor
难度 2/5 1-3 小时 新手友好度 88/100
linagora/cozy-client#1763 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
area:desktop area:ui bug platform:macos
难度 2/5 1-3 小时 新手友好度 67/100
anthropics/claude-code#106183 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 2 天内回复
-
CMS video element: "CmsVideoPlugin" sets `volume = 0`, so videos cannot be unmuted on Android Chrome未关闭needs-triage Platform(Default)
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复