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

v-model.lazy in custom component with moment instance as value does not sync when component emits 'change' #5743

Closed
radisb opened this issue May 24, 2017 · 3 comments

Comments

@radisb
Copy link

@radisb radisb commented May 24, 2017

Version

2.3.3

Reproduction link

https://jsfiddle.net/xnyhfL9h/

Steps to reproduce

Create a custom component , accept a moment instance through a prop, clone it, modify the clone and emit the modified clone using a 'change' event. If the data has been bound to the parent through v-model.lazy, the parent's data does not update. However if it is bound with separate :value and @change , then it updates correctly.

What is expected?

The parent's value should be updated

What is actually happening?

Nothing. Parent bound data does not get updated

@posva

This comment has been minimized.

Copy link
Member

@posva posva commented May 24, 2017

v-model in components is just sugar syntax, it doesn't support modifiers. Using a change or input event doesn't change anything in components. You can actually use that if you prefer: https://vuejs.org/v2/guide/components.html#Form-Input-Components-using-Custom-Events

@tmorehouse

This comment has been minimized.

Copy link

@tmorehouse tmorehouse commented Oct 20, 2018

@posva after some simple testing, I discovered that v-model.number and v-model.trim both appear to work with custom input components, while v-model.lazy doesn't.

After inspecting the component's root element, I do see a _vModifiers property which lists the modifiers if they are present (i.e. ._vModifiers = { lazy: true }. But when inspecting the vm.$el, this property doesn't appear.

It would be nice to be able to check within the component if this modifier is set on v-model, and then one could change which event is being $emited or change when input is fired.

I suppose one could create their own lazy prop on the component, but it would be nice to have the option to detect the .lazy modifier, so that the custom input would work like a standard input.

@SzNagyMisu

This comment has been minimized.

Copy link

@SzNagyMisu SzNagyMisu commented Feb 19, 2019

It would be nice to have a possibility to have v-model.lazy on custom components. Something configurable like

export default {
  model: { lazyEvent: 'my-custom-lazy-event' } // defaulting to 'change'
}

@posva ? Is it daydreaming 😎 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.