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 on text input on chrome mobile not behaving #9299

Closed
bbsimonbb opened this issue Jan 10, 2019 · 33 comments
Closed

v-model on text input on chrome mobile not behaving #9299

bbsimonbb opened this issue Jan 10, 2019 · 33 comments

Comments

@bbsimonbb
Copy link

bbsimonbb commented Jan 10, 2019

Version

2.5.16

Reproduction link

https://jsbin.com/juzakis/1

Steps to reproduce

Open the jsbin on Chrome mobile. Type some text in both inputs.

What is expected?

v-model should be updating the model on input, after each keystroke, as in the Decomposed input.

What is actually happening?

The v-model input is not updated until the user leaves the field.


Seems like an issue to me. Chrome desktop shows the correct behaviour - the model is updated after every keystroke.
The editable jsbin is here. This issue came from
this stackoverflow question

@posva
Copy link
Member

posva commented Jan 10, 2019

Works fine on Chrome mobile...

@posva posva closed this as completed Jan 10, 2019
@bbsimonbb
Copy link
Author

That was quick. Still not working for me and I'm not the only person to have observed this. I'll put up a video if I get a moment.

@posva
Copy link
Member

posva commented Jan 10, 2019

If I cannot reproduce, I cannot do much so a video won't help unfortunately... I guess you have a plugin that interferes with how input event is triggered or something. Maybe the keyboard you are using on the phone is different

@bbsimonbb
Copy link
Author

Yup. We just tried it in the office and every Android we tried shows the problem. Galaxy S4, S7 and S9, a Wiko Ufeel Prime. Safari on Iphone 7 behaves as expected, doesn't show the issue. My anonymous jsbin has expired, so here's a new one if you'd like to retest

@bbsimonbb
Copy link
Author

The issue seems even more random than described. On the v-model input, updates are more frequent when adding chars in the middle of the string, or when deleting. Chars added at the end of the string are only updated when the user leaves the field or when when the cursor is repositioned!

The Decomposed input is meant to behave exactly like v-model, but in fact behaves much better - updates are processed with every keystroke. On all 5 phones tried!

All phones have default keyboard, and no chrome extensions that anyone's admitting.

@janein
Copy link

janein commented Jan 18, 2019

Experienced it on a Honor 8, but it worked fine on other Androids like Pixel 2, Samsung Galaxy something, ...

@bbsimonbb
Copy link
Author

Was the Honor 8 in some weird language :-) We're all in France, so I'm wondering if the language setting of the keyboard has something to do with it (5 out of 5 androids tried in our office showed the issue)

@janein
Copy link

janein commented Jan 18, 2019

My phone (the Honor 8) is set to German/English and the other (working) ones to pure German.
Maybe it's because I'm using the Google Keyboard and not the default one?

@jckkk
Copy link

jckkk commented Feb 10, 2019

This is also an issue on OnePuls 6 and Samsung Galaxy S7. Tested on Firefox and Chorme with Gboard and Samsung Keyboard (Samsung only). CodeBoard keyboard on OnePlus works with no issue, so this seems to be keyboard dependent.

@skegel13
Copy link

Also experiencing this in Chrome on a Pixel 2, Brave and Firefox on Pixel 1. It does pick up the input if the first character is a number, but not letters.

Works fine on desktop.

@alex-gru

This comment has been minimized.

@dumboxp
Copy link

dumboxp commented Mar 7, 2019

I was able to reproduce the same behaviour using the following simple JSFiddle (which uses Vue.js v2.6.8)

For mobile phones: https://jsbin.com/damesok/1
JS Fiddle: https://jsfiddle.net/DumboMustermann/xrqcs14a/

@StrangeWill
Copy link

StrangeWill commented Mar 31, 2019

Experiencing this on:

Chrome: 73.0.3683.90
OS: Android 8.10; Moto G (5s) Plus Build

The model properly updates when I:

  • Tap outside of the field.
  • Click the "enter" key on the keyboard (but only once, wont do it if I change it and tap it again, I have to tap out/into the field to be able to use the enter key again)
  • When I blank the field out entirely (right on the last backspace it fires).

Will not properly update when I:

  • Type any character into the field
  • Hitting enter if enter has already been hit once and the model already updated once
  • During the removal of any character using backspace

@alex-gru
Copy link

alex-gru commented Apr 1, 2019

@posva commented in the related issue #9777:

This is because you are using a keyboard that does composition (it may underline the text while typing). It is similar to Chinese input, Japanese input and many others. Vue intentionally waits if composing. Numbers and spaces terminate the composition mode

in my YouTube demo above, you indeed see this underlined text, so apparently, there is this "composition" process going on. do you all agree, that most users (and as you can see even developers) are not aware of this composition step and its limitations? is there no way to ignore this and still update the model as expected? thanks @posva!

@bbsimonbb

This comment has been minimized.

@alex-gru
Copy link

alex-gru commented Apr 1, 2019

@bbsimonbb I totally agree and I'm with you! I guess we should poke @posva 🙊

@posva
Copy link
Member

posva commented Apr 1, 2019 via email

@alex-gru
Copy link

alex-gru commented Apr 1, 2019

@posva see comment above.

Same here, please fix this behaviour.

Device: OnePlus 3T (Android 8.0.0, Build A3003_28_181206)
Browser: Chrome (72.0.3626.105)
Keyboard: Gboard (7.7.12.219989447-release-arm64-v8a)
Language: reproducible with English and German

Another scenario is shown in the video below. You see an input element and a submit button. The button's :disabled condition validates the input model to be non-empty. Apparently, the validation is only triggered when the text is numeric, or the text is delimited by special characters like comma or space.

https://youtu.be/7BEhQQoBgN4

EDIT: added YouTube link

@bbsimonbb
Copy link
Author

@posva you say v-model is not like v-on:input, but the docs say the opposite. I'm not raising this issue because I'd like it to work some way. I'm raising it because the docs say it works like X and it very plainly doesn't. A solution to this issue would be to correct the docs. (but v-on:input works very well, works like using a hard keyboard, even if I'm using composition)

I'm using Gboard. Gboard might well be on all the phones used when we tested this, since it's installed by default.

@LinusBorg
Copy link
Member

LinusBorg commented Apr 1, 2019

@posva you say v-model is not like v-on:input, but the docs say the opposite. I'm not raising this issue because I'd like it to work some way. I'm raising it because the docs say it works like X and it very plainly doesn't.

The section of the docs that you link to explicitly talks about using v-model on components. Which is something very different from using v-model on DOM form elements like you do in your demo.

That is documet here, and you can see that v-model does a lot of things that @input doesn't do, i.e. offer modifierts for lazy, trim etc, as well as dynamically deciding for which event to listen depending on the element (input for text inputs, change for select elements etc.). In general, it has a lot of internal logic that a plain v-on event listener doesn't provide/have.

One of these things that v-model does is what @posva described: it intentionally waits for spaces or numbers before updating if the input is a "composing" one. That's what he means.

Please note that I'm not claming who's right about the reported issue since I haven't investigated so far - I merely wanted to correct your specific misconception about the docs and the behaviour of v-model.

Either way, I would agree that docs can be improved regarding this behaviour

Edit: Your example works fine with my normal keyboard, and it shows the described behaviour with the GBoard keyboard indeed.

@bbsimonbb
Copy link
Author

@LinusBorg Ok I'm starting to get it, but I don't agree ! The section of docs I quote is, as you say, v-model for components, but when it says "remember that", it's clearly saying what v-model does in general, not just on components.

Understanding all that, I can see that the current behaviour is consistent and there's a reason for it (the input is 'provisional' and might change). But even when you understand it, it doesn't seem right to wait indefinitely and not see your model updated. I think the best choice in most situations will be to ditch v-model and use v-input. (Remember we're talking about text input in any languages on any Android device with default settings. It's a big slice of the pie). If this behaviour suits the input of logographic (chinese) characters, couldn't we add a test to switch it off for latin characters?

@yyx990803
Copy link
Member

#9777 (comment)

@bbsimonbb
Copy link
Author

Ok well thanks to everyone who took the time to talk me through this. Clearly I got a bit stuck on one idea of how it should work. I'll try and be a bit sharper next time.

@alex-gru
Copy link

alex-gru commented Apr 2, 2019

Same here. Thanks everyone! 🙏

posva added a commit to posva/vue that referenced this issue Apr 2, 2019
Ignore `composing` value on the input and eagerly modify the value while
the user is still composing a value. vuejs#9299 vuejs#9777
radoslawkoziol added a commit to radoslawkoziol/vue-autocomplete that referenced this issue Apr 9, 2019
You can not use v-model for some mobile browsers (like Chrome for android) in this case.
I've spent a few hours before solving this. I've found that you couldn't type in the input when using mobile browsers with virtual keyboard - simply after typing one letter input was cleared instantly.

It looks like there's some problem with emitting an event in Vue. 

More info:

vuejs/vue#9299
@victorforissier
Copy link

just use @input instead of v-model....

here, it works:

https://jsbin.com/juzakis/1/edit?html,js,output

@monkeydkon
Copy link

I came across this issue today as well. But i really cannot understand it.
I am currently developing 2 several apps using Vue and Capacitor.
In one of the apps this issue cannot be seen at all, but at the other it exists. I managed to sort it out using a custom v-eager directive implementation I found on github.
But what is the matter?

@rukshn
Copy link

rukshn commented May 22, 2020

I also came across with the same issue today on my Android chrome mobile browser.

The v-on:input or v:on-change is not firing when typing on the mobile device.

This has to work because the input field is attached to an auto-complete and it is not working because of this

@aremu-smog
Copy link

aremu-smog commented May 22, 2020 via email

@rukshn
Copy link

rukshn commented May 22, 2020

Use v-on:keyup for to monitor changes in input boxes. v-on:change should be used select boxes

This still does not work when it comes to mobile. The problem is the v-on:change , v-on:input , or v-on:keyup nothing works on a mobile browser

@themobileprof
Copy link

This should be triggered by a space bar, due to the composition thingy.
Here is a work around:

Replacing v-model="search" with v-bind:value="search" and v-on:input="search= $event.target.value" works.

Reference: [https://github.com//issues/8231]

@FelixRe0
Copy link

For anybody still having the issue:

Adding autocomplete="off" to the form or text-field disables the functionality, resolving any issues. Please note the side-effects.
Also working on vuetify forms if added to v-text-field

Reference:
https://www.w3docs.com/snippets/html/how-to-disable-browser-autocomplete-and-autofill-on-html-form-and-input-fields.html
https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion

@nolimitdev

This comment has been minimized.

@posva
Copy link
Member

posva commented Sep 24, 2020

I have answered this question so many times already and even provided an alternative (#9814). #9777 (comment) explains it best.

@nolimitdev this is enough, as a maintainer, I deserve to be treated better than that (especially when it's repeated behavior).

@vuejs vuejs locked as resolved and limited conversation to collaborators Sep 24, 2020
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