I’ve been running into issues with the NumberField component. Everything works fine when you simply use <NumberField value={value} onChange={setValue} />
, but the moment you don’t set the state to exactly what was inputted it breaks.
Take this example:
<NumberField
label="Quantity"
inputMode="numeric"
value={val}
onChange={num => {
console.log('onChange', num);
if (!num) {
setVal(num);
return;
}
const parsed = Number(num);
if (parsed > 10) {
setVal('10');
return;
}
setVal(num);
}}
max={10}
required
/>
After entering e.g. 12 it correctly snaps back to 10, but further inputs do not cause a call to onChange. It seems like using onInput would work here, but I would prefer not doing that as the docs explicitly state not to.
I’ve also noticed that onChange is never called again after the value has been set to undefined
Hope this can be fixed, thanks.