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

controlled input caret jumps to end when input is modified #36

Closed
dustingetz opened this issue Oct 27, 2014 · 3 comments
Closed

controlled input caret jumps to end when input is modified #36

dustingetz opened this issue Oct 27, 2014 · 3 comments

Comments

@dustingetz
Copy link

Here is a demo repo with reduced test case.

The final commit in this repo fixes the bug via the react-async-input monkey patch described here.

Uncomment the monkey patch on line 13 of index.html to see the broken behavior.

@dustingetz
Copy link
Author

I dont think the React maintainers consider this a bug in React, because idiomatic React uses state for things like this. Even if your state is limited to a single stateful React component at the top of the hierarchy, all onChange handlers eventually forward through a setState call so the bug does not get triggered. All the state has to be lifted entirely out of React to trigger the bug which is of course the style Quiescent forces.

This is all probably wrong, there are many related issues in the React repo in various states and this issue can probably be repro'ed in various Flux architectures where state is not backed by react

@Raynos
Copy link

Raynos commented Nov 18, 2014

This is a known issue with most virtual-dom things.

I actually feature detect for this in my virtual dom implementation ( https://github.com/Raynos/virtual-hyperscript/blob/master/index.js#L55-L62 ). I specifically ensure that setting of the value property on a DOM node goes through a softset hook which implements a "check before set" semantics. This means you cant overwrite the state of the DOM with the same state but reset the cursor.

@levand
Copy link
Owner

levand commented Mar 8, 2015

Sorry for the long turnaround time on this. There is now a fix for it in master, though you'll have to use one of the new uncontrolled inputs

See the documentation at https://github.com/levand/quiescent/blob/master/docs.md#cursor-jumping-and-controlled-inputs

@levand levand closed this as completed Mar 8, 2015
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

No branches or pull requests

3 participants