-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
INPUT/TEXTAREA value setter with the same value should not change text selection #2412
Comments
This sounds reasonable. Any thoughts, @rniwa? |
Seems reasonable to me. There's a big question regarding how the general selection API and selection in text fields are associated though: w3c/selection-api#83 |
I implemented this in Firefox today, and immediately ran into regression test failures on React apps. React, in So if in a React app you focus an input that function was called on, the cursor will be at the end. With the changes for this issue it will be in the beginning. A minimal React-less testcase that is currently interoperable across at least Chrome, Firefox, and Safari (no Windows on hand right this second to test Edge) and changes behavior with the proposed spec changes:
I am sufficiently worried about web compat fallout here that I'm suspending work on this in Firefox for the moment. |
Thanks. It looks like in Edge the cursor stays at the beginning. I'm hopeful @tkent-google is still willing to try this in Chrome; I think examples like the one you mention will probably get better UX, not worse, as moving the cursor seems like an unintended side effect of that line in React (which just intends to set the dirty value flag, per the comment in the code above that line). If we for some reason can't get this working for input, I imagine we'll still want to do it for textarea, given that the majority of browsers do nothing in that case. |
I still think changing the INPUT value setter behavior is ok. |
Great :). Hopefully we can ship in Chrome and then Boris can feel more comfortable about the web-compat impact for shipping in Firefox. |
Was one of those meant to be "ReactDOMTextarea.js"? |
Oh, Yes :) |
https://html.spec.whatwg.org/multipage/forms.html#dom-input-value
https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-value
Value setter for INPUT and TEXTAREA update text selection unconditionally.
As for TEXTAREA, Chrome, Edge, Firefox and Safari do nothing if new value is same as the old value.
As for INPUT. Chrome and Safari update text selection, and Edge and Firefox do nothing.
I propose updating the specification so that these value setters do nothing if new value is same as old value. I'll update Chrome implementation if the specification is changed.
The text was updated successfully, but these errors were encountered: