cleave icon indicating copy to clipboard operation
cleave copied to clipboard

@blur events don't fire

Open cloud-tribal opened this issue 8 years ago • 7 comments

Can be easily reproduced. @blur events don't fire. @input does. Haven't tested others.

cloud-tribal avatar Jan 20 '17 04:01 cloud-tribal

Yes, it wont handle blur event. If you need that here is a quick fix: add @blur="updateValue($event.target.value)" behind @import=“up... in line 2 of Cleave.vue.

luventa avatar Jan 20 '17 06:01 luventa

Thanks, I think you meant @input, and just out of curiosity, what additional work would be required to add this to the codebase?

cloud-tribal avatar Jan 20 '17 08:01 cloud-tribal

And btw adding that doesn't work

cloud-tribal avatar Jan 20 '17 15:01 cloud-tribal

@cloud-tribal It shall work. @blur="yourcallback()" also needs to be added in cleave element as an attr,

luventa avatar Jan 22 '17 02:01 luventa

No it doesn't work. Cleave component doesn't know about blur. An artificial event emitter for blur must be added in order for it to work.

  methods: {
    updateValue(value) {
      this.$emit('input', value);
    },
    blurValue(value) {
      this.$emit('blur', value);
    }
  },

cloud-tribal avatar Jan 22 '17 17:01 cloud-tribal

Also I would suggest passing the actual input events themselves to @input and @blur so that you can treat them as regular inputs in the parent component.

Otherwise, when working with other inputs in a form, to obtain value of all inputs you must consider different arguments: e.target.value for regular inputs and then value (for cleave).

I can submit pull request to do this if that's ok.

Please share your thoughts. Relatively new to contributing to OSS

cloud-tribal avatar Jan 22 '17 17:01 cloud-tribal

Yes, your suggestion is right, welcome PR. It's Chinese spring festival these days, I may cannot make quick response to it.

And the quick fix i mentioned shall is shown below.

Cleave.vue

<template>
  <input type="text" v-bind:value="value"
    @input="updateValue($event.target.value)" 
    @blur="updateValue($event.target.value)" />
</template>

luventa avatar Jan 25 '17 10:01 luventa