Bug 208835

Summary: Safari doesn't preserve user selection upon updating input value with the same value programmatically
Product: WebKit Reporter: Viacheslav Moskalenko <jason.rammoray>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: ahmad.saleem792, bradrini, rniwa, simon.fraser, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: BrowserCompat, InRadar
Version: Safari 13   
Hardware: Mac   
OS: macOS 10.15   
Attachments:
Description Flags
Demonstrating the issue in Safari none

Description Viacheslav Moskalenko 2020-03-09 15:03:33 PDT
Created attachment 393078 [details]
Demonstrating the issue in Safari

Details:
* an input field has some value (say "initial value")
* a user clicks somewhere in the middle of the input field (say, right after "l")
* the input field's value is getting updated programmatically with the same value after n seconds

Expected:
The user's selection (cursor position) doesn't change.

Actual:
A cursor jumps to the end of the input's value (right after "e").

Demo:
https://jsbin.com/pipefoluha/1/edit?html,js,output

Notes:
The cursor positions is correctly handled in:
* Chrome [80.0.3987.132 (Official Build) (64-bit), macOS 10.15.3 (19D76)]
* Firefox [73.0.1 (64-bit), macOS 10.15.3 (19D76)]
Comment 1 Radar WebKit Bug Importer 2020-03-09 15:07:48 PDT
<rdar://problem/60244975>
Comment 2 Ahmad Saleem 2022-12-16 03:37:13 PST
I am not able to reproduce the jump issue in Safari 16.2 and Safari Technology Preview 160 but the field does not get focus like Chrome Canary 110 and Firefox Nightly 110 while showing the caret at "iIn" (I as Caret) position, which might be separate issue.

Can someone else confirm and we mark this bug appropriately while using this test case for other bug tracking purpose? Thanks!
Comment 3 Ryosuke Niwa 2022-12-16 16:10:23 PST
Doesn't reproduce anymore.