Bug 246029 - Text selection sometimes jumps back to original position on tap to change text selection
Summary: Text selection sometimes jumps back to original position on tap to change tex...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: Safari 16
Hardware: iPhone / iPad iOS 16
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-10-04 10:41 PDT by mkuo
Modified: 2022-10-11 10:42 PDT (History)
3 users (show)

See Also:


Attachments
Minimal repro (249 bytes, text/plain)
2022-10-04 10:41 PDT, mkuo
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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>