Bug 225024

Summary: Incorrect selection after spliting text node in range
Product: WebKit Reporter: Comandeer <vepomoc>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: ahmad.saleem792, karlcow, megan_gardner, rniwa, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: BrowserCompat, InRadar
Version: Safari 14   
Hardware: Unspecified   
OS: Unspecified   

Description Comandeer 2021-04-24 16:18:12 PDT
Reproduction steps:

1. Open https://jsfiddle.net/Comandeer/ge4qu390/
2. Place the caret at the end of the second line.
3. Press Backspace.

Expected result:

The last character in the second line is deleted.

Actual result:

The selection jumps to the beginning of the paragraph.

If the reproduction steps are repeated with subsequent lines, the selection will jump to the last place of the split.

The splitting logic imitates what happens in CKEditor 4 during pressing Backspace. The error is not reproducible if the custom splitting logic is replaced with the native Text#splitText() method, but due to a bug in Chrome (https://bugs.chromium.org/p/chromium/issues/detail?id=1201161) connected with this method, I was searching for some workaround and discovered this issue.

It works fine in Firefox 88.0.
Comment 1 Comandeer 2021-04-24 16:31:07 PDT
A similar issue is reproducible in Blink: https://bugs.chromium.org/p/chromium/issues/detail?id=1202439
Comment 2 Radar WebKit Bug Importer 2021-05-01 16:19:16 PDT
<rdar://problem/77423626>
Comment 3 Ahmad Saleem 2022-06-02 11:44:52 PDT
I am able to reproduce this bug in Safari 15.5 on macOS 12.4. From the linked Chrome bug link, it was fixed in Chrome 91 and it was already working with Firefox 88.
Comment 4 Ahmad Saleem 2023-02-06 12:53:28 PST
It seems to work fine now in WebKit ToT (259906@main). I am changing this to "RESOLVED CONFIGURATION CHANGED".