Bug 246029

Summary: Text selection sometimes jumps back to original position on tap to change text selection
Product: WebKit Reporter: mkuo
Component: UI EventsAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: megan_gardner, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Safari 16   
Hardware: iPhone / iPad   
OS: iOS 16   
Attachments:
Description Flags
Minimal repro none

Description mkuo 2022-10-04 10:41:33 PDT
Created attachment 462793 [details]
Minimal repro

Overview: In contenteditable div or textarea, sometimes when I try to move the text selection by tapping on text, the selection changes to position that I tapped, but then jumps back to the previous position. 

Steps to reproduce:
Comment 1 mkuo 2022-10-04 10:50:53 PDT
Steps to reproduce: 
1. Open attached minimal repro in Safari iOS
2. Tap after a word, like after "the"
3. Then tap before the word 
4. (If issue doesn't reproduce on first try, try repeating steps 2/3)

Actual results:
Sometimes, when tapping to change the text selection, the selection will change for a split second then jump back to the original position.

I used Web Inspector to add an event listener on "selectionchange" events

document.addEventListener('selectionchange', () => console.log(document.getSelection()))

and saw that whenever the issue reproduces, one tap causes two "selectionchange" events (the first to the tapped position, the second back to the previous position). This *seems* to reproduce more frequently when the selection menu (menu with options to select/select all) is visible.

Expected results:
Tap to change the text selection changes the text selection to the position that was tapped.

Browser/Hardware
Safari on iPhone 13 mini on iOS 16.0.2
Comment 2 Radar WebKit Bug Importer 2022-10-11 10:42:18 PDT
<rdar://problem/101040185>