Description
Bug description
When starting to type international number in empty input, entering +
doesn't display it right away, only when entering number after that. It seems confusing and makes end users wonder if something is not working.
I'd expect seeing +
in input right away.
Didn't dig too much into the code, but seems that problem is with getFormattedNumber()
, which returns empty string if passed raw value is +
. It's used internally in useMask
's onInput
handler and event.target.value
is mutated / cleared, as method return empty string in that case.
Maybe that's expected behaviour. If so, would like to understand motivation behind this
As workaround for this, I'm not calling onInput
if input value is +
// ...
const { onInput, onKeyDown } = useMask(pattern);
return {
<input
onKeyDown={onKeyDown}
onInput={(e) => {
if (e.target.value === '+') return;
onInput(e);
}}
/>
}
Reproduction URL
https://playground.typesnippet.org/mui-phone-input/
Reproduction steps
- Clear pre-filled country code
- Enter
+
with keyboard - no change in input
Screenshots
Logs
No response
Browsers
Safari
OS
Mac