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 mobile not updating until a space is pressed #8231

Closed
choyg opened this issue May 22, 2018 · 11 comments
Closed

v-model on mobile not updating until a space is pressed #8231

choyg opened this issue May 22, 2018 · 11 comments

Comments

@choyg
Copy link

choyg commented May 22, 2018

Version

2.5.16

Reproduction link

https://jsfiddle.net/yyx990803/xkkbfL3L/?utm_source=website&utm_medium=embed&utm_campaign=xkkbfL3L

Steps to reproduce

https://www.youtube.com/watch?v=y8CASLitwdw

  1. Type into input/textarea with Android (don't have iOS to test with)

What is expected?

Input data should be updated per keypress

What is actually happening?

Input data is only updated after a space is pressed


Reproduced on Android 7.1 Chrome 66 and Android 4.4.2 Firefox 60

@posva
Copy link
Member

posva commented May 22, 2018

it's because you're in composition mode (For accents, or languages like Japanese) (see the underline)
This is completely normal because until composition isn't finished, the browser Vue doesn't inform about something being typed

@posva posva closed this as completed May 22, 2018
@choyg
Copy link
Author

choyg commented May 22, 2018

If I understand you correctly, this will happen for all keyboards?

Current documentation implies this should only happen for keyboards that require an IME

@sc85
Copy link

sc85 commented Jul 12, 2018

Is there a way to still update the model directly and not wait for the compositionend event? I am working on a live search and on Android it is simply not working before adding space, moving focus etc. but the idea is that it is live...

@ArtistNeverStop
Copy link

ArtistNeverStop commented Aug 9, 2018

Ok, I dont know if there is another solution for this issue, but it can be solved with a simple directive:

Vue.directive('$model', {
  bind: function (el, binding, vnode) {
    el.oninput = () => (vnode.context[binding.expression] = el.value)
  }
})

using it just like

<input v-$model="{toBind}">

It works fine for me.
Android 8.0 (Chrome 68)
Android (Firefox 61)

@richrd

This comment has been minimized.

@nolimitdev

This comment has been minimized.

@richrd

This comment has been minimized.

@jgalentine007

This comment has been minimized.

@kasperkamperman
Copy link

kasperkamperman commented Oct 29, 2019

For me, this was easier than using a directive:

Instead of:

v-model="searchQuary"

do:

:value="searchQuery"
@input="e => searchQuery = e.target.value"

@ghost

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.

@vuejs vuejs locked as resolved and limited conversation to collaborators Sep 24, 2020
@vuejs vuejs deleted a comment from tiagomatosweb Sep 24, 2020
@vuejs vuejs deleted a comment from nolimitdev Sep 24, 2020
@vuejs vuejs deleted a comment from iabdulin Sep 24, 2020
@vuejs vuejs deleted a comment from Syler921 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

8 participants