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 is not updating the value of an input when it has a focus #8346

Closed
mciesin opened this issue Jun 13, 2018 · 12 comments
Closed

v-model.lazy is not updating the value of an input when it has a focus #8346

mciesin opened this issue Jun 13, 2018 · 12 comments

Comments

@mciesin
Copy link

mciesin commented Jun 13, 2018

Version

2.5.16

Reproduction link

https://jsfiddle.net/twyqL8k4/

Steps to reproduce

  1. Type Jacob into the input.
  2. Hit enter.

What is expected?

Value property of the input element should be changed to Joseph, as was the value of the name property in the Vue instance.

What is actually happening?

Value property of the input element is not being changed.


The value of the input is correctly being updated when using v-model without .lazy modifier.

@haoqunjiang
Copy link
Member

haoqunjiang commented Jun 13, 2018

Can not reproduce on macOS 10.13.5 + Chrome 67.0.3396.87 / Safari 11.1.1 (13605.2.8).
Could you update issue description to include you operating system and browser version?

Misunderstood this issue at first glance. It is a bug.

@posva
Copy link
Member

posva commented Jun 13, 2018

As a temporal workaround, you can do blur the input then focus it (I used a ref on the input)

if (name === 'Jacob') {
    this.$refs.input.blur()
    this.name = 'Joseph';
    await this.$nextTick()
    this.$refs.input.focus()
}

@mciesin
Copy link
Author

mciesin commented Jun 14, 2018

Another workaround that suited me was to replace v-model with appropiate :value and @change :)

@haoqunjiang haoqunjiang self-assigned this Jun 14, 2018
@rof20004
Copy link

rof20004 commented Jun 14, 2018

To me this worked, I think is not a bug.

@tonyraoul
Copy link

According to a comment in sourcecode Focused element should never be updated.

From this bug it seems like it should, the update function will not be called unless user press enter or blur anyways it seems redundant to me.

@rof20004
Copy link

Well, to me worked, without changes or fixes.

@softlad45
Copy link

works well for me

@haoqunjiang
Copy link
Member

The bug is introduced by this commit:
60da366

But reverting it will reopen #7153
The only fix that can solve both bugs is to revert that commit along with nextTick implementation. So now adding a "nextTick related" label

@tonyraoul
Copy link

sodatea please review my pr, no need to revert the entire commit just the restriction on updating lazy elements while focused

@haoqunjiang
Copy link
Member

@tonyraoul Remove that restriction will cause another issue as described in #7153

@deerchao
Copy link

This is annoying. Will it be resolved in next version?

@yyx990803
Copy link
Member

Closed via 080dd97

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

No branches or pull requests

8 participants