Created attachment 353841 [details] Bug reproduction Focusing at the beginning of an input, caret at position 0, then setting `input.value = input.value` will move caret position to the end of the input. This is inconsistent with other browser's implementations (tested on Chrome 70.0.3538.77 and Firefox 63.0.1). Also inconsistent with WebKit's <textarea> element, where setting `textarea.value = textarea.value` won't move the caret. I've created a JSFiddle to give you an example. Also, attached a video with reproduction. JSFiddle: https://jsfiddle.net/foavjy3n/2/ (code also pasted below) ///////////////////////////////////////////// <main> <p>Start typing <strong>BEFORE</strong> "test".</p> <p>Focus will be moved at the end of the INPUT, while this won't happen for the TEXTAREA.</p> <div> <label for="input-text">Plain text input</label> <input id="input-text" type="text" value="test"> </div> <div> <label for="textarea">Textarea</label> <textarea id="textarea">test</textarea> </div> </main> <script> function monitorValueFor(id) { const element = document.getElementById(id); element.addEventListener('input', ({ target }) => { target.value = target.value; }); } monitorValueFor('input-text'); monitorValueFor('textarea'); </script>
Created attachment 355262 [details] Patch
Note: patch is supposed to do the same thing as HTMLTextAreaElement::setValueCommon (See lines 384 to 387 of HTMLTextAreaElement.cpp), which is why I used the same comment.
Comment on attachment 355262 [details] Patch Attachment 355262 [details] did not pass mac-ews (mac): Output: https://webkit-queues.webkit.org/results/10076909 New failing tests: editing/input/setting-same-value-on-input-should-not-change-caret-position.html imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-value-interactions.html imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change.html fast/forms/range/range-set-attribute.html fast/forms/number/number-validity-badinput.html
Created attachment 355265 [details] Archive of layout-test-results from ews102 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews102 Port: mac-sierra Platform: Mac OS X 10.12.6
Comment on attachment 355262 [details] Patch Attachment 355262 [details] did not pass mac-wk2-ews (mac-wk2): Output: https://webkit-queues.webkit.org/results/10076935 New failing tests: fast/forms/number/number-validity-badinput.html imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-value-interactions.html imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change.html fast/forms/range/range-set-attribute.html editing/input/setting-same-value-on-input-should-not-change-caret-position.html
Created attachment 355267 [details] Archive of layout-test-results from ews107 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews107 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
Comment on attachment 355262 [details] Patch Attachment 355262 [details] did not pass mac-debug-ews (mac): Output: https://webkit-queues.webkit.org/results/10077048 New failing tests: editing/input/setting-same-value-on-input-should-not-change-caret-position.html imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-value-interactions.html imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change.html fast/forms/range/range-set-attribute.html fast/forms/number/number-validity-badinput.html
Created attachment 355269 [details] Archive of layout-test-results from ews112 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews112 Port: mac-sierra Platform: Mac OS X 10.12.6
Comment on attachment 355262 [details] Patch Attachment 355262 [details] did not pass win-ews (win): Output: https://webkit-queues.webkit.org/results/10077129 New failing tests: editing/input/setting-same-value-on-input-should-not-change-caret-position.html fast/forms/number/number-l10n-input.html fast/forms/range/range-set-attribute.html fast/forms/number/number-validity-badinput.html
Created attachment 355270 [details] Archive of layout-test-results from ews203 for win-future The attached test failures were seen while running run-webkit-tests on the win-ews. Bot: ews203 Port: win-future Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Comment on attachment 355262 [details] Patch Attachment 355262 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: https://webkit-queues.webkit.org/results/10076946 New failing tests: editing/input/setting-same-value-on-input-should-not-change-caret-position.html imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-value-interactions.html imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change.html fast/forms/range/range-set-attribute.html fast/forms/number/number-validity-badinput.html
Created attachment 355271 [details] Archive of layout-test-results from ews123 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews123 Port: ios-simulator-wk2 Platform: Mac OS X 10.13.6
Sorry for the broken patch. Next time I'll be more cautious. Note: my patch (https://bugs.webkit.org/attachment.cgi?id=355262) is missing a -expected.txt file for the new test. I'm not going to submit a new one just for this, since it would trigger all the testing process. ----------- I'll try to work a bit more on this, but it's clear that I'm missing something. For example: I'm now thinking that the fix should be applied just to TextFieldInputType::setValue, but any approach I take leaves at least these 2 tests failing: imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-value-interactions.html imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change.html
Try to match the spec as closely as possible : https://html.spec.whatwg.org/#dom-input-value Your current patch seems to bypass work that we are supposed to do as per spec, only the cursor position change is supposed to be impacted.
Comment on attachment 355262 [details] Patch r- due to the new test failures.
Created attachment 438558 [details] Submit patch to check layout test result
Created attachment 438571 [details] patch to check layout test result
Created attachment 438574 [details] Patch
Could you please review this change? I think this patch is ready for review.
Comment on attachment 438574 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=438574&action=review > Source/WebCore/ChangeLog:14 > + Reviewed by NOBODY (OOPS!). This line should go below the bug link (with a blank line in between). > LayoutTests/imported/w3c/ChangeLog:14 > + Reviewed by NOBODY (OOPS!). Ditto
Comment on attachment 438574 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=438574&action=review >> Source/WebCore/ChangeLog:14 >> + Reviewed by NOBODY (OOPS!). > > This line should go below the bug link (with a blank line in between). Ok, I will move this in the next patchset. >> LayoutTests/imported/w3c/ChangeLog:14 >> + Reviewed by NOBODY (OOPS!). > > Ditto Done.
Created attachment 438993 [details] Patch For Landing
Committed r282898 (242026@main): <https://commits.webkit.org/242026@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 438993 [details].
<rdar://problem/83425241>