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

Random event triggered on @input with v-model #5586

Closed
rdzar opened this issue May 3, 2017 · 2 comments · Fixed by #5589
Closed

Random event triggered on @input with v-model #5586

rdzar opened this issue May 3, 2017 · 2 comments · Fixed by #5589

Comments

@rdzar
Copy link

rdzar commented May 3, 2017

Version

2.3.2

Reproduction link

https://jsfiddle.net/9zcdvdxu/4/

Steps to reproduce

  • Click in the text input
  • Type any letter (h)
  • Hit enter
  • Two events triggered
  • Hit enter again; no event (expected)

What is expected?

Enter to not trigger an event, just like it normally does if you do not type anything before it.

Same behavior as in 2.6.2 see https://jsfiddle.net/hcnok29L/4/

What is actually happening?

It adds an extra event when hitting the enter key, but it doesn't do so when hitting the enter key normally without anything typed in front of it.


We couldn't find any reason or explanation for this within the changelogs, assuming it is not intended behavior. A customer complained that our autocomplete stayed open after they hit the enter key and it didn't previous week. The fix was easy, move the keydown keyup for canceling the up-coming request. But is was kinda strange bug.

@posva
Copy link
Member

posva commented May 3, 2017

Thanks for reporting this. It looks like the problem comes from 98326ce
At the moment, a simple workaround is to use a :value with @input (or check if the value actually changed)

@posva
Copy link
Member

posva commented May 3, 2017

Maybe checking if composing is true at https://github.com/vuejs/vue/blob/dev/src/platforms/web/runtime/directives/model.js#L122

I'll create a PR and test a bit

posva added a commit to posva/vue that referenced this issue May 3, 2017
yyx990803 pushed a commit that referenced this issue May 7, 2017
* Prevent unecessary input trigger with v-model

Fix #5586

* Add test for compositionend on v-model + @input

* [skip ci] Rename tests for compositionend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants