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

feat(model): add .eager modifier to v-model #9814

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

posva
Copy link
Member

@posva posva commented Apr 2, 2019

Add an .eager modifier to v-model that ignore composing value on the input and eagerly modify the value while the user is still composing a value. #9299 #9777.
See the rationale behind this at #9777 (comment)

Since the default keyboard on Android, GBoard, does composing by default, I think it makes sense to have a modifier to disable the composing behaviour while still benefitting from using v-model.

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

Ignore `composing` value on the input and eagerly modify the value while
the user is still composing a value. vuejs#9299 vuejs#9777
@posva posva changed the title feat(model): add .eager modifier feat(model): add .eager modifier to v-model Apr 3, 2019
@golber9
Copy link

golber9 commented Sep 17, 2019

Do you have a forecast of when it will be released? Thanks

@ghost
Copy link

ghost commented Sep 24, 2020

Thanks for the PR, @posva! I hope that feature be approved soon.
Don't forget to put a note in the docs or new issues will be created mentioning this issue. I guess that the site of Vue.js should have a section talking about known issues pointing to links so the users should read there first before create new issues if there's nothing created before (like stackoverflow does), it avoids duplicated topics.

@nolimitdev, I hope you read this PR. I think there's no better solution than that. Thank you for contribuition in #8231!

@nolimitdev
Copy link

nolimitdev commented Sep 24, 2020

@lvfxbr One thing I do not understand... how it is possible that in old VUE 1 v-model works well out of the box on android device during auto prediction... I mentioned it in #8231 in 2018y but got no reaction and today most favourite comment in #8231 was incomprehensibly removed by maintainer. I noticed this bug a long time ago during migration from VUE 1 to VUE 2. Please test someone it in old VUE 1 and confirm that it works or not. So v-model can technically work on VUE 1 but can not on VUE 2 and VUE 3? Maybe Im missing something I did not read source code what is the difference.

@ghost
Copy link

ghost commented Sep 24, 2020

@nolimitdev, I did a test in latest update of Vue 1 (1.0.28) from 2016. I created a repository to test this here, I tested in my smartphone and really, the v-model works fine:

This is the branches I created for compare the vue versions:
https://github.com/lvfxbr/vue-tests/branches

This is the live tests, everyone can test it in mobile:
https://codesandbox.io/s/test-vue1-v-model-in-mobile-6yeq3
https://codesandbox.io/s/test-vue2-v-model-in-mobile-gq5pj

We can investigate what changed Vue 1 to Vue 2.

@guska8
Copy link

guska8 commented Nov 19, 2020

Hey guys, i've been wondering if this .eager feature is gonna come out? thank you
EDIT: so i was trying to make a input that executes a search while the user types on mobile and fixed based on sming comment:
https://forum.vuejs.org/t/why-is-my-value-inside-event-and-not-event-target-value/12737/7

<my-component
        :value="text"
        :placeholder="placeholder"
        @input.native="handleInput"
/>

props: {
    value: {
      type: String,
      default: ''
    }
},

methods: {
    handleInput (event) {
      if(e.isComposing){
        // if button delete from mobile is pressed
        if(e.target.value === ''){
          this.text = this.query.slice(0, -1)
        }else{
          this.text = e.target.value
        }
      }else{
        this.text = e.target.value
      }
  }
}

the .eager would be better but i hope it helps while it's not released

@CyberAP
Copy link

CyberAP commented Jan 20, 2021

For those who are still waiting for the fix and don't want to replace v-model with an input event here's the solution to force .eager mode:

<input v-model="myModel" @input="$event.target.composing = false">

@nolimitdev
Copy link

nolimitdev commented Jan 20, 2021

@posva did you please noticed @lvfxbr 's comment #9814 (comment) ? Thanks. It seems that no .eager is needed just to investigate how it is possible that VUE v1 did not have this bug but v2 and v3 has.

@rightaway
Copy link

Will this be fixed in Vue 2 or 3? Anything we can do to help this get merged?

kjellmf added a commit to orbat-mapper/orbat-mapper that referenced this pull request Aug 7, 2021
@clawrence121
Copy link

For those who are still waiting for the fix and don't want to replace v-model with an input event here's the solution to force .eager mode:

<input v-model="myModel" @input="$event.target.composing = false">

This worked for me using Nuxt 2.15!

@inlandfx
Copy link

For those who are still waiting for the fix and don't want to replace v-model with an input event here's the solution to force .eager mode:

<input v-model="myModel" @input="$event.target.composing = false">

This worked for me using Nuxt 2.15!

Worked like a charm

@CyberAP
Copy link

CyberAP commented Jun 6, 2022

@yyx990803 would it be possible for this PR to make it into 2.7?

@mryellow
Copy link

mryellow commented Jul 6, 2022

It would appear that v-model is broken and does not work on mobiles when applied to non-component elements.

Either the documentation is wrong or the functionality is wrong.

However it seems all these issues are being pushed into the "It's all your fault stupid user" basket instead of the problem being solved. Complete with reports of this issue being prematurely closed. Meanwhile potential solutions are left to go stale.

This issue could be better handled.

It is not working as intended and reports of such are continually being obstructed

gammaSpeck added a commit to gammaSpeck/salary-converter that referenced this pull request Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants