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 behaves inconsistently in comparison to docs #8723

Closed
richrd opened this issue Aug 28, 2018 · 5 comments
Closed

v-model behaves inconsistently in comparison to docs #8723

richrd opened this issue Aug 28, 2018 · 5 comments

Comments

@richrd
Copy link

richrd commented Aug 28, 2018

Version

2.5.17

Reproduction link

https://vuejs.org/v2/guide/forms.html#Text

Steps to reproduce

First off, the docs claim here that using v-model is identical to using v-bind:value="searchText" and v-on:input="searchText = $event.target.value".

It does have the same behavior on desktop, but with chrome on android the behavior is different. When using v-model on android/chrome the model only gets updated when pressing space, enter, backspace or unfocusing the field (and maybe in some other cases). The model does not update when in the middle of typing a word. However when using v-bind and v-on:input the model gets updated as it is supposed to.

It seems like v-model isn't binding the input event on android. The correct behavior can be achieved by adding v-on:input regardless of whether v-model or v-bind:value is used. This applies to input and textarea elements.

What is expected?

The behavior is expected to be the same on all platforms: The model should update live with every keypress.

What is actually happening?

On chrome on android the model isn't updated on every keypress. This can be reproduced with the example inputs that are shown in the docs.


This is a problem when for example creating a list that should be filtered live with user input. I'm wondering whether this is a bug or a documentation issue. I feel like it's a bug since the same code has different behavior on different platforms.

@posva
Copy link
Member

posva commented Aug 28, 2018

it's talking about v-model in components which is indeed what is explained but is different from input's v-model


Please, next time consider using the forum, the Discord server or StackOverflow for questions first. But feel free to come back and open an issue if it turns out to be a bug 🙂

@posva posva closed this as completed Aug 28, 2018
@xPaw
Copy link

xPaw commented Aug 28, 2018

@posva Then why does the documentation talk about v-model in input?

As per the report, input model is not immediately updated on Android when typing. There's plenty of issues reported in Vue regarding this specific use case already. Either the documentation needs to be updated to reflect that or Vue internally should handle it better.

It automatically picks the correct way to update the element based on the input type.

This doesn't particularly sound correct to me.

@richrd
Copy link
Author

richrd commented Aug 28, 2018

I did search for this quite a bit. I also agree that at least the docs could be updated as this is a very unexpected inconsistency. The example text input in the docs (reproduction link) behaves differently on android/chrome compared to desktop/chrome. For the record Angular 2 and above has no such issue (regardless of composition mode)

@richrd
Copy link
Author

richrd commented Aug 28, 2018

I see this is what the docs say about this:

For languages that require an IME (Chinese, Japanese, Korean etc.), you’ll notice that v-model doesn’t get updated during IME composition. If you want to cater for these updates as well, use input event instead.

Why is this also happening for English and other languages that don't require IME? Is IME the same as autocomplete/word suggestions, because disabling those gives me the desired behaviour.

@danstewart
Copy link

Made a PR to add this to the documentation here: vuejs/v2.vuejs.org#1798

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

No branches or pull requests

4 participants