Fix: fixing cursor position in case of a bad input or bad pasting
There was a bug: if you input an illegal character or paste an illegal text the cursor used to move right, whereas the value hadn't had changed. This commit corrects the issue by preserving cursor position on each keyDown and restoring it on bad validation.
Also, some code refining was done: getting ride of "var" declarations, using more "destructuring", using arrow functions and changing React.Component to React.PureComponent.
Also, I revealed more issues, but hasn't figured out how to fix them easily.
- Enhancement. DynamicInput has "separator" props, which can be either: dot or comma. It would be good to substitute the separator on incorrect input automatically. I.e. when it is set to comma and user inputs a dot, then accept it as a comma. Now user is unable to input a dot in this case. And vise versa.
This looks a bit frustrating. Users often mistake dot and comma, so auto-substitution would be helpful.
- Bug. If "thousand" is used, then the user is unable to input "separator" at the end of the number. User has to input all the digits, then to return cursor back and to input fraction "separator" (dot or comma).
It is inconvenient and confusing. First time I didn't understand what was wrong and why I can't make a fractional part.
UPD. I managed to propose a fix for issue "2" in the last commit.