finput
finput copied to clipboard
Copy and paste broken when caret in middle of value
To reproduce issue:
- Follow Developing section in readme and load
localhost:3000in browser - Type
12in default finput field - Select all and copy
- Position caret between
1and2 - Paste
Observed (broken) behaviour:
12 is completely replaced with 12 making it look like no paste has happened.
Expected:
Value should now be 1,212
The fix needs to be tested on both mac & windows. We should probably test edge cases such as positioning the caret before and after thousands/decimal delimiters before pasting.
@ryanggrey I am working on this bug. Would it be possible to give me some advice about possible combinations and edge cases to test ?
@msuperina I guess cases would include (I'm making up my own notation here so let me know if it isn't clear):
- pasting at the beginning of existing value:
[paste 12]12 => 1,212 - pasting in the middle of existing value where there are no delimiters:
1[paste 12]2 => 1,122 - pasting in the middle of existing value before a thousands delimiter:
1[paste 12],212 => 112,212 - pasting in the middle of existing value after a thousands delimiter:
1,[paste 12]212 => 112,212 - pasting at the end of existing value:
12[paste 12] => 1,212 - pasting in the middle of existing value before a decimal delimiter:
12[paste 12].00 => 1,212.00 - pasting in the middle of existing value after a decimal delimiter:
12.[paste 12]00 => 12.12. There's additional behaviour to consider here - what if the value pasted after the decimal delimiter is more than the number of allowed decimal digits? Not sure what should happen here. One option is to truncate the pasted value (12.[paste 1234]00 => 12.12) - pasting in the middle of existing decimal value:
12.1[paste 12]2 => ?. Again not sure what the behaviour here should be. One option is to treat as though we'd expanded to over the allowed decimals and then truncated it to allowed decimal places (12.11)
And then permutations of those with different options settings. There's possibly more cases that I'm missing.