Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@blur events don't fire #4

Open
cloud-tribal opened this issue Jan 20, 2017 · 7 comments
Open

@blur events don't fire #4

cloud-tribal opened this issue Jan 20, 2017 · 7 comments

Comments

@cloud-tribal
Copy link

cloud-tribal commented Jan 20, 2017

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

@luventa
Copy link
Member

luventa commented Jan 20, 2017

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.

@cloud-tribal
Copy link
Author

cloud-tribal commented Jan 20, 2017

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
Copy link
Author

cloud-tribal commented Jan 20, 2017

And btw adding that doesn't work

@luventa
Copy link
Member

luventa commented Jan 22, 2017

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

@cloud-tribal
Copy link
Author

cloud-tribal commented Jan 22, 2017

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
Copy link
Author

cloud-tribal commented Jan 22, 2017

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

@luventa
Copy link
Member

luventa commented Jan 25, 2017

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants