Inputmask
Inputmask copied to clipboard
Copy&Paste not working properly
- Describe the bug When I paste the value to input, input element behaves like there is no value on input but value is in there.
- OS: MacOS 10.14.6
- Browser 86.0.4240.198
- Inputmask version all>5.0.3 In 5.0.0 version, there is no problem.
The 'input' event does not fire.
How to solve this?
Indeed pasting a value into masked input seems to be broken since 5.0.4. Had to lock the version to 5.0.3 in our Vue project. This issue should be re-opened.
My issue was related to custom Vue plugin implementation.
You could listen for paste event on the input:
<input
type="text"
v-model="form.ringnumber"
@paste="pasteEvent"
/>
And then define a method which sets the data prop:
pasteEvent(e) {
this.form.ringnumber = e.clipboardData.getData('text');
},
Try to check if that works.
I also had this bag. But in my case copy and paste doesn't work with onBlur for input-text for specific mask.
mask={'r 999 rr 99[9]'}
definitions={CAR_VALIDATION_DEFINITIONS.cyrillicLike}
const CAR_VALIDATION_DEFINITIONS = { cyrillicLike: { r: { validator: '[АаВвЕеКкМмНнОоРрСсТтУуХх]', }, }, };
If I remove onBlur, it works just fine. Locked in 5.0.3 in our project.
I faced one more time this issue. When I removed autoUnmask option, it was fixed. It is weird :/
A quick workaround for jQuery. Works for me.
$(document).on('paste', 'input[inputmode]', function() {
$(this).trigger('input');
});
Can someone make a codepen of jsfiddle? Did someone tryu with the latest version on github?
Here's the jsfiddle: https://jsfiddle.net/bvrnpfju/2/ The problem persists. I have the impression that Vue input event is not being fired.
In my case I emit "input" event in onBeforePaste:
onBeforePaste: function (pastedValue, opts) {
setTimeout(() => this.$el.trigger("input"), 0);
return pastedValue;
}