Input Number: Avoid Number Zero as First Character
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- react
- Área
- frontend
Línea de trabajo
Comienza con el reproductor reproducible enlazado de StackBlitz y con el comportamiento de los eventos y del valor controlado del componente InputNumber. Traza cómo se formatea un 0 como primer carácter antes de que se ejecute el callback personalizado. La tarea estará terminada cuando los usuarios puedan evitar que aparezca el 0.00 inicial o puedan controlar el valor de forma fiable antes de que se actualice la UI, con este comportamiento cubierto por una prueba de regresión.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- CSS
- Estrellas
- 8.3k
- Forks
- 1.2k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de primefaces/primereact
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
primefaces/primereact#8552 ·
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
primefaces/primereact#8550 ·
-
Row checkbox selection tick is invisible in Landing Page Theme sectionPosiblemente ocupada @Prakash1185 la tomó hace 149 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
primefaces/primereact#8545 ·
-
Dependency conflict between jspdf v4 and jspdf-autotable during npm installPosiblemente ocupada @Kamran92 la tomó hace 164 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
primefaces/primereact#8537 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 58/100
primefaces/primereact#8551 ·
Todos los issues de primefaces/primereact
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
marmelab/react-admin#11431 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
stripe/react-stripe-js#728 ·
-
[Upload Grade C dataset] the pop-up changes it's size while uploading the document => Jumping effectAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
epam/statgpt-admin-frontend#305 ·
Los mantenedores suelen responder en 1 día