Bug 276926

Summary: In a shadow root hosting element that has contenteditable=plaintext-only, the last inserted text node gets deleted as a whole instead of character-by-character
Product: WebKit Reporter: Zacky Ma <zacky>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: cdumez, megan_gardner, rniwa, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Safari 17   
Hardware: Mac (Apple Silicon)   
OS: macOS 14   
Bug Depends on:    
Bug Blocks: 148695    

Zacky Ma
Reported 2024-07-22 21:11:00 PDT
Given an element like so: ``` <div contentediable=plaintext-only><template shadowrootmode="open"><slot></slot></template></div> ``` If a user type the following text character by character (as opposed to pasting the whole text with line breaks): abc<Enter> de<Enter> fgh Hit Backspace, "fgh" is deleted, caret moves right after "e", after this, hitting Backspace deletes character-by-character which is expected. Seems if the container is a `<pre>` element, this issue doesn't occur. Example: https://codepen.io/marchbox/pen/oNrLWjY There is a previous unclosed bug here: https://bugs.webkit.org/show_bug.cgi?id=266700. But from my testing, seems `contenteditable=true` works fine, but `contenteditable=plaintext-only` doesn't.
Attachments
Zacky Ma
Comment 1 2024-07-23 11:07:22 PDT
Also, if you have the "Add period with double-space" feature turned on in macOS, double pressing Space also deletes the last added text node (and places the period right after any text that's left).
Zacky Ma
Comment 2 2024-07-25 23:56:38 PDT
I tested a bit more: - `contenteditable=true` does indeed still trigger this bug - in addition to Backspacing the last line, when the caret is in the middle or beginning of a previous line, hitting Backspace also trigger this bug
Radar WebKit Bug Importer
Comment 3 2024-07-29 21:11:14 PDT
Note You need to log in before you can comment on or make changes to this bug.