Input Number: Avoid Number Zero as First Character
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- react
- Ambito
- frontend
Direzione di ricerca
Inizia dal riproduttore StackBlitz collegato e dal comportamento degli eventi e del valore controllato del componente InputNumber. Traccia come viene formattato uno 0 come primo carattere prima dell'esecuzione del callback personalizzato. Il lavoro è completato quando gli utenti possono impedire la visualizzazione dello 0.00 iniziale oppure controllare in modo affidabile il valore prima dell'aggiornamento dell'UI, con questo comportamento coperto da un test di regressione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- CSS
- Stelle
- 8.3k
- Fork
- 1.2k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di primefaces/primereact
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
primefaces/primereact#8552 ·
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
primefaces/primereact#8550 ·
-
Row checkbox selection tick is invisible in Landing Page Theme sectionForse già presa @Prakash1185 l’ha presa 150 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
primefaces/primereact#8545 ·
-
Dependency conflict between jspdf v4 and jspdf-autotable during npm installForse già presa @Kamran92 l’ha presa 164 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
primefaces/primereact#8537 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
primefaces/primereact#8551 ·
Tutte le issue di primefaces/primereact
Issue simili
-
area:desktop area:ui bug platform:macos
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
anthropics/claude-code#106183 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 2 giorni
-
RGAA5
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 8 giorni
-
feature:App-Tour feature:Chat ready Web
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
digitalfabrik/integreat-app#4523 · 2 reazioni ·
I maintainer di solito rispondono entro 3 giorni
-
[Button] 图标按钮内边距样式问题Aperta🐞 bug 🧐 unconfirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Tencent/tdesign-vue-next#7036 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno