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 breaks selectionStart #3029

Closed
kucherenkovova opened this issue Jun 3, 2016 · 7 comments
Closed

v-model breaks selectionStart #3029

kucherenkovova opened this issue Jun 3, 2016 · 7 comments
Assignees
Labels

Comments

@kucherenkovova
Copy link

@kucherenkovova kucherenkovova commented Jun 3, 2016

Vue.js version

1.0.24

Reproduction Link

https://github.com/kucherenkovova/piano/tree/BUG-report-vue
go to demo folder and open index.html

Steps to reproduce

Input something into the Email layout input field.
Put the cursor in the middle of your text.
Hit backspace on the virtual keyboard.

What is Expected?

The text will be removed in the cursor position.

What is actually happening?

The text removes from the end of the string. selectionStart attribute is changed somehow by Vue.js

P.S. You can test it on other input elements which do not have v-model on it.Everything will work well.

@posva
Copy link
Member

@posva posva commented Jun 4, 2016

Hello!

Thanks for filing the issue 😄 . Please follow the Issue Reporting Guidelines and provide a minimal JSFiddle or JSBin containing a set of reproducible steps that can lead to the behaviour you described.

I cloned your repo and tested it on chrome, it works well. Next time provide a simple repro. People can't go through your whole application to help...

@kucherenkovova
Copy link
Author

@kucherenkovova kucherenkovova commented Jun 6, 2016

Thanks for the feedback. I'll provide a gh-pages link soon. It's impossible to reproduce the bug on the codepen or jsfiddle due to Piano.js nature.

@posva
Copy link
Member

@posva posva commented Jun 6, 2016

I see, in that case it may be due to Piano.js. It'd be great if you can create a repro without pianojs 👍

@kucherenkovova
Copy link
Author

@kucherenkovova kucherenkovova commented Jun 6, 2016

@posva Hi again! Here's a codepen with repro
Steps to reproduce:

  1. Insert text into first input
  2. Select some text
  3. Click a button near your input

Looking forward for your response!

@posva
Copy link
Member

@posva posva commented Jun 6, 2016

Thanks! I found the bug. The update resets those values so caching them here and taking them back there actually solves the issue. I'm not sure about how to test this though. I may have to write an e2e test

PS: I'm doing this tomorrow, going to sleep 😴

@posva posva added bug and removed need repro labels Jun 6, 2016
@posva posva self-assigned this Jun 6, 2016
@posva
Copy link
Member

@posva posva commented Jun 8, 2016

I didn't had internet yesterday 😢 I hope being able to do it this evening

@posva
Copy link
Member

@posva posva commented Jun 10, 2016

Finally got internet back. I'm having some trouble creating a test that breaks as a unit test. I'll try again today with an e2e test although it's a by overkill. Calling the blur method on the input doesn't behave the same way as actually doing.
The fix I came up with is not setting the input value if it hasn't changed at blur. It's basically adding _toString(self._watcher.value) !== el.value to the conditions here

posva added a commit to posva/vue that referenced this issue Jun 14, 2016
Fix vuejs#3029
Force setting the value actually resets selectionStart and selectionEnd
No test is added because you cannot simulate the bug by using
input.blur()
yyx990803 added a commit that referenced this issue Jun 14, 2016
Fix #3029
Force setting the value actually resets selectionStart and selectionEnd
No test is added because you cannot simulate the bug by using
input.blur()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants