-
-
Notifications
You must be signed in to change notification settings - Fork 451
Description
Describe the issue
So I have a 2-in-1 combo here:
- When a
cm-linehas top padding, tapping on the top padding causes Safari to set the selection to be at the the first text character in the line, rather than the character closest to the tap. Chrome is smart enough to do the right thing. Unfortunately I think this may need a kludge since I can't seem to get Safari to behave more like Chrome. - When the editor loses focus, and a tap triggers the bug above, if the first character of the line happens to be on a widget (even if the widget is explicitly contenteditable=false!!), the editor completely ignores the selection and resumes the last selection. This happens because the tap triggers
focusandselectionchange;focussets a 10ms timer, andselectionchangecatches the selection to be within the widget, which has ignoreEvent returning true, causing the selection to be ignored; subsequently the focus timeout fires and resets the selection to the editor's last know position.
The repro link below sets up a widget at the beginning of the first line, and a CSS style for an exaggerated top padding for cm-view for ease of reproduction. (In our production app, the padding is 1-2px, so the reproduction is seemingly random depending on whether the fat finger hit the 2-4px zone or not)
As demonstrated in the video below from the repro link:
0-5s: Put the cursor at the end of the document (initial setup).
6-9s: Tap on the top padding of line 1 (with the widget at the beginning of line). Notice the cursor is still at the end of the document (bug 2).
10-12s: Tap on the top padding of line 2 (without the widget at the beginning of line). Notice the cursor has been moved to the beginning of line 2 (bug 1).
12s-15s: Repeat with line 1, notice cursor is still at line 2 (bug 2).
ScreenRecording_11-14-2025_22-44-00_1.mov
Browser and platform
iOS 18/26 Safari