We want to allow user to type any digit, dot or comma symbols and replace comma with dot on the fly.
const numberAccept = /[\d.,]+/g;
const parseNumber = string =>
(string.replace(",", ".").match(numberAccept) || []).join("");
But when user types comma symbol cursor visually jumps to the wrong position before new dot symbol.
We want to allow user to type any digit, dot or comma symbols and replace comma with dot on the fly.
But when user types comma symbol cursor visually jumps to the wrong position before new dot symbol.
Sandbox example:
https://codesandbox.io/s/istarkovrifm-numberformat-e6jfu?fontsize=14