Inputmask icon indicating copy to clipboard operation
Inputmask copied to clipboard

Copy&Paste not working properly

Open mersanuzun opened this issue 4 years ago • 11 comments

  • 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.

mersanuzun avatar Nov 20 '20 06:11 mersanuzun

The 'input' event does not fire.

dogwatch avatar Nov 24 '20 19:11 dogwatch

How to solve this?

Seiya82 avatar Dec 10 '20 11:12 Seiya82

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.

kadyrleev avatar Dec 16 '20 12:12 kadyrleev

My issue was related to custom Vue plugin implementation.

mersanuzun avatar Dec 22 '20 17:12 mersanuzun

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.

DeBelserArne avatar Dec 29 '20 20:12 DeBelserArne

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.

rs-8 avatar Dec 30 '20 10:12 rs-8

I faced one more time this issue. When I removed autoUnmask option, it was fixed. It is weird :/

mersanuzun avatar Jan 02 '21 17:01 mersanuzun

A quick workaround for jQuery. Works for me.

$(document).on('paste', 'input[inputmode]', function() {
    $(this).trigger('input');
});

Zikov avatar Feb 18 '21 09:02 Zikov

Can someone make a codepen of jsfiddle? Did someone tryu with the latest version on github?

RobinHerbots avatar May 26 '21 08:05 RobinHerbots

Here's the jsfiddle: https://jsfiddle.net/bvrnpfju/2/ The problem persists. I have the impression that Vue input event is not being fired.

lucraraujo avatar Jul 07 '21 17:07 lucraraujo

In my case I emit "input" event in onBeforePaste:

onBeforePaste: function (pastedValue, opts) {
    setTimeout(() => this.$el.trigger("input"), 0);
    return pastedValue;
}

atos1990 avatar Oct 04 '21 11:10 atos1990