RESOLVED FIXED Bug 191255
Setting input's value to the same value moves caret at end of input
https://bugs.webkit.org/show_bug.cgi?id=191255
Summary Setting input's value to the same value moves caret at end of input
Giovanni Piller Cottrer
Reported 2018-11-05 02:37:21 PST
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>
Attachments
Bug reproduction (363.41 KB, video/quicktime)
2018-11-05 02:37 PST, Giovanni Piller Cottrer
no flags
Patch (3.34 KB, patch)
2018-11-19 03:31 PST, Giovanni Piller Cottrer
no flags
Archive of layout-test-results from ews102 for mac-sierra (2.51 MB, application/zip)
2018-11-19 04:32 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews107 for mac-sierra-wk2 (2.95 MB, application/zip)
2018-11-19 04:44 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews112 for mac-sierra (2.25 MB, application/zip)
2018-11-19 05:23 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews203 for win-future (12.81 MB, application/zip)
2018-11-19 05:23 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews123 for ios-simulator-wk2 (17.44 MB, application/zip)
2018-11-19 05:25 PST, EWS Watchlist
no flags
Submit patch to check layout test result (1.89 KB, patch)
2021-09-18 07:05 PDT, Joonghun Park
no flags
patch to check layout test result (2.00 KB, patch)
2021-09-18 17:23 PDT, Joonghun Park
no flags
Patch (9.49 KB, patch)
2021-09-18 18:13 PDT, Joonghun Park
no flags
Patch For Landing (9.45 KB, patch)
2021-09-22 17:06 PDT, Joonghun Park
no flags
Giovanni Piller Cottrer
Comment 1 2018-11-19 03:31:04 PST
Giovanni Piller Cottrer
Comment 2 2018-11-19 03:49:58 PST
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.
EWS Watchlist
Comment 3 2018-11-19 04:32:24 PST
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
EWS Watchlist
Comment 4 2018-11-19 04:32:26 PST
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
EWS Watchlist
Comment 5 2018-11-19 04:44:12 PST
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
EWS Watchlist
Comment 6 2018-11-19 04:44:14 PST
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
EWS Watchlist
Comment 7 2018-11-19 05:23:35 PST
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
EWS Watchlist
Comment 8 2018-11-19 05:23:37 PST
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
EWS Watchlist
Comment 9 2018-11-19 05:23:44 PST
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
EWS Watchlist
Comment 10 2018-11-19 05:23:55 PST
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
EWS Watchlist
Comment 11 2018-11-19 05:25:06 PST
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
EWS Watchlist
Comment 12 2018-11-19 05:25:08 PST
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
Giovanni Piller Cottrer
Comment 13 2018-11-19 09:50:05 PST
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
Chris Dumez
Comment 14 2018-11-19 09:57:06 PST
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.
Ryosuke Niwa
Comment 15 2018-11-19 13:59:18 PST
Comment on attachment 355262 [details] Patch r- due to the new test failures.
Joonghun Park
Comment 16 2021-09-18 07:05:33 PDT
Created attachment 438558 [details] Submit patch to check layout test result
Joonghun Park
Comment 17 2021-09-18 17:23:07 PDT
Created attachment 438571 [details] patch to check layout test result
Joonghun Park
Comment 18 2021-09-18 18:13:12 PDT
Joonghun Park
Comment 19 2021-09-22 09:41:01 PDT
Could you please review this change? I think this patch is ready for review.
Simon Fraser (smfr)
Comment 20 2021-09-22 10:28:49 PDT
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
Joonghun Park
Comment 21 2021-09-22 16:57:36 PDT
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.
Joonghun Park
Comment 22 2021-09-22 17:06:01 PDT
Created attachment 438993 [details] Patch For Landing
EWS
Comment 23 2021-09-22 17:40:20 PDT
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].
Radar WebKit Bug Importer
Comment 24 2021-09-22 17:42:03 PDT
Note You need to log in before you can comment on or make changes to this bug.