Closed yoink00 closed 9 years ago
I'm not sure if this is generally applicable but in my use case it is useful to be able to quickly enter large values using short cuts.
This change will also prevent backspace from going back through history when non in edit mode and the field was doing unexpected things when there were invalid characters in the field. To fix this I've limited the accepted keys in the field.
I like it, but what does t
stand for?
It stands for thousands (so you can use either 't' or 'k'). I have to admit the 't' comes from a legacy application I am replacing :-)
Instead of adding all this logic inside this component, maybe we can add a onKeyDown
prop so it will allow developers the possibility to change the value based on the received key event?
Sure. That makes sense. I'll tweak the pull request along these lines.
I was thinking of splitting this in two. The k,t and m shortcuts would be removed and implemented using the new onkeydown prop and the key filter to prevent non-numeric characters would stay.
Does that make sense?
Actually .
and ,
could be allowed as well. But otherwise it makes sense :)
Of course :-) On Tue, 29 Sep 2015 at 23:13, Tommy notifications@github.com wrote:
Actually . and , could be allowed as well. But otherwise it makes sense :)
— Reply to this email directly or view it on GitHub https://github.com/tleunen/react-number-editor/pull/16#issuecomment-144206239 .
Thanks,
Stuart
Tel: 07989 301439
I didn't add ',' to the list of allowed characters as the way strings being converted to numbers (using a Number cast) doesn't support commas either as thousand separators or decimal points. I think do that we should use something like numeral.js to format and parse the strings.
Thanks for the work @yoink00 !