Bug 225024 - Incorrect selection after spliting text node in range
Summary: Incorrect selection after spliting text node in range
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: Safari 14
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-04-24 16:18 PDT by Comandeer
Modified: 2022-06-02 11:44 PDT (History)
5 users (show)

See Also:


Attachments

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