-
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[number field] onValueChange not being called when input value is changed #579
Comments
Yes it's by design. The reason is partial input may not be parseable as a valid number, so it can't properly be called in realtime/on change. |
Can this potentially be made available on the hook variant of I understand the concern, but it gives a worse UX (less immediate feedback) because of an edge case, for a lack of a better term - when a used enters invalid values. In the happy flow path, the UX is just worse without any benefit. |
I think the main concern is with compositional inputs such as pinyin, which depends on the client's locale/number system. The input already blocks most invalid input before it can be typed in, but composition events aren't blocked yet represent incomplete data that can't be parsed? This behavior matches the RA library, though it doesn't state what "partial input":
Open to suggestions or PRs to improve this behavior however |
I suggest the |
Maybe an A side note, made me think of #600. |
This means that the component must be controlled though, no? Or at the very least - moves the burden of parsing the data to see if the number is valid (yet) to the consumer. When |
@bengry it does seem ok to me that @oliviertassinari In our API, instead of |
Let's label this "ready to take", if anybody is interested and has an idea of how to do this we can discuss here ~ |
Steps to reproduce
Link to live example:
https://codesandbox.io/p/sandbox/wpqjmg?file=%2Fsrc%2FApp.tsx%3A10%2C43-10%2C56
Steps:
Current behavior
onValueChange
not being called when input value is changedYou can see that the text below the input will remain
value: 0
until you focus out of the input. The blur leads toonValueChange
being called.Expected behavior
onValueChange
being called when input value is changedContext
Thanks for adding support for decimals in the new version of the number input ❤️
I'm working on an interactive calculator in which changes to input values should be reflected in calculations that are shown in the UI.
I tried to debug the issue and I found that on each change I reach this part of the code:
base-ui/packages/mui-base/src/NumberField/Root/useNumberFieldRoot.ts
Line 607 in 78d4abd
Because
event.isTrusted === true
in this case, we call onlysetInputValue
without callingsetValue
(which internally callsonValueChange
)I'm not sure if it's by design or not. So forgive me if I classified this issues as bug 🐛 by mistake.
Your environment
npx @mui/envinfo
Search keywords: onValueChange
The text was updated successfully, but these errors were encountered: