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 Editing | Assignee: | 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
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Zacky Ma
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
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
<rdar://problem/132778602>