Inputmask
Inputmask copied to clipboard
Paste value when all select in inputfield not working good
Hi!
When I try paste a value in a field this is not working good, This is just increase the selected value. example: This is my format options: alias: "decimal" allowMinus: true autoGroup: true clearMaskOnLostFocus: false digits: 2 digitsOptional: false greedy: false groupSeparator: "" groupSize: 3 max: "99999.99" min: -99999.99
I write in the field: 12345.22
I selected all:
I would like paste 9876.12 But i got this:
If I delete the value before paste it will working good.
Can you help me?
- OS: windows 10
- Browser Google Chrome 99.0.4844.82
- Inputmask version: 5.0.8-beta.17
And this is reproducible on the demo page. https://robinherbots.github.io/Inputmask/
Do you have any updates on this issue?
I just signed up only to ask this question :) I'm about to replace the autoNumeric-library (https://github.com/autoNumeric) in our project with this wonderful masterpiece, many thanks to @RobinHerbots for your gratuitous work for the community!
BUT: Overwriting using paste when everything is selected is part of the very basic functionality of fields in browsers that users of our software are used to. That's why we couldn't use this library at all, unfortunately it's a no go in our specific case.
Hence the question: Is there a workaround?
Maybe using onBeforePaste/onBeforeMask somehow? Or perhaps an honorable person could give a hint, how to patch the source code at out site somehow, please? I am currently experimenting with version 5.0.7.
@nikola-velinov ,
Ok maybe it's time to fix this.
Dear Robin, sir,
I wouldn't say "it's time to fix" because it's not a hard error. It's just an unique behavior that it has ever since. Please let us agree on the much friendlier: "Maybe it's time to adjust the behavior.." :)
Faithfully yours Nikola
Am 16. Juni 2023 16:37:18 MESZ schrieb Robin Herbots @.***>:
@nikola-velinov ,
Ok maybe it's time to fix this.
-- Reply to this email directly or view it on GitHub: https://github.com/RobinHerbots/Inputmask/issues/2603#issuecomment-1594801650 You are receiving this because you were mentioned.
Message ID: @.***>
Can someone have a try with 5.0.9-beta.17
@RobinHerbots you are a genius!
I tested three simple configurations. And the pasting over full selection looks good!
I also tested pasting over partial selections and without selection - there are some troubles here, especially with dates. But maybe this is described in other issues, I don't know.
Configuration "date": alias: 'datetime', inputFormat: 'dd.mm.yyyy', outputFormat: 'dd.mm.yyyy', displayFormat: 'dd.mm.yyyy', placeholder: 'TT.MM.JJJJ', min: '01.01.1900', max: '31.12.9999', clearMaskOnLostFocus: true, clearIncomplete: true
Configuration "non-negative integer": alias: 'numeric', min: '0', max: '99999', radixPoint: ',', digits: 0, groupSeparator: '', importDataAttributes: false, rightAlign: false, positionCaretOnClick: 'none', placeholder: '0', clearMaskOnLostFocus: true, clearIncomplete: true, allowMinus: false, inputType: 'text', stripLeadingZeroes: true, SetMaxOnOverflow: false, shortcuts: null, enforceDigitsOnBlur: true, substituteRadixPoint: false
Configuration "numeric mask 999": mask: '999', numericInput: true, importDataAttributes: false, rightAlign: false, positionCaretOnClick: 'none', placeholder: '0', clearMaskOnLostFocus: true, clearIncomplete: false
Results in attached pdf Paste_tests.pdf
I have encountered two different types of issues for currency mask on release 5.0.8.
When pasting an integer, all selected figures are doubled. If the cursor is placed somewhere between the figures, it works fine. I came to the conclusion that the issue is related with method pasteEvent in eventhandler.js. This pasting issue is resolved with Commit 7c99ce5a but currently only available with a beta release.
When pasting a floating number into a currency field the behaviour feels strange. The issue arise because pasting a floating number into a floating number means that two points are present in the resulting string (e.g. pasting 4.5 into 1.2 results to 4.51.2 or 14.5.2 or 1.4.52 or 1.24.5). The new string gets normalized by the currrency mask. This make sense but is not intuitive. Maybe it would make more sense for currency fields to replace the old value instead of extending it.
The floating number issue seems to be tightly related with the currency mask, whereas the integer issue is more general.