-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Issue resulting in loss of cursor position in controlled inputs isn't fixed #6563
Comments
You must not defer updating the value of the input or the selection information will be lost. I.e., it will think you rejected the change and then updated it, at which point there is no apparent place to put the cursor other than at the end. |
So then which bug was fixed, could you explain? |
The bug that was fixed was related to synchronously updating the input state. This was always supported, and broke in 15.0.0. Asynchronously updating without losing the position was never supported as @syranide noted. |
Ok, thanks! |
Sorry but one more question about "You must not defer updating the value of the input or the selection information will be lost": so as all we know setState defers rendering. So my question is why when setState defers rendering cursor isn't lost when I do the same via setTimeout - cursor is lost? |
Loosely speaking, |
Thanks for great answer. Now I understand. My last thought is: event when component is rerenderd asynchronously but it's focused I see no problem to set value and preserve cursor. Haven't dug deep but it might work. You may not answer me sorry for taking your time :) |
In 15.0.1 release I see "Fixed issue resulting in loss of cursor position in controlled inputs.
@spicyj in #6449"
But actually this bug isn't fixed. Please consider this example:
https://jsfiddle.net/2ayxpag4/4/
Steps to reproduce:
The text was updated successfully, but these errors were encountered: