<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>276926</bug_id>
          
          <creation_ts>2024-07-22 21:11:00 -0700</creation_ts>
          <short_desc>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</short_desc>
          <delta_ts>2024-07-29 21:11:14 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>HTML Editing</component>
          <version>Safari 17</version>
          <rep_platform>Mac (Apple Silicon)</rep_platform>
          <op_sys>macOS 14</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>148695</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Zacky Ma">zacky</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cdumez</cc>
    
    <cc>megan_gardner</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2047680</commentid>
    <comment_count>0</comment_count>
    <who name="Zacky Ma">zacky</who>
    <bug_when>2024-07-22 21:11:00 -0700</bug_when>
    <thetext>Given an element like so:

```
&lt;div contentediable=plaintext-only&gt;&lt;template shadowrootmode=&quot;open&quot;&gt;&lt;slot&gt;&lt;/slot&gt;&lt;/template&gt;&lt;/div&gt;
```

If a user type the following text character by character (as opposed to pasting the whole text with line breaks):

abc&lt;Enter&gt;
de&lt;Enter&gt;
fgh

Hit Backspace, &quot;fgh&quot; is deleted, caret moves right after &quot;e&quot;, after this, hitting Backspace deletes character-by-character which is expected.

Seems if the container is a `&lt;pre&gt;` element, this issue doesn&apos;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&apos;t.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2047834</commentid>
    <comment_count>1</comment_count>
    <who name="Zacky Ma">zacky</who>
    <bug_when>2024-07-23 11:07:22 -0700</bug_when>
    <thetext>Also, if you have the &quot;Add period with double-space&quot; feature turned on in macOS, double pressing Space also deletes the last added text node (and places the period right after any text that&apos;s left).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2048535</commentid>
    <comment_count>2</comment_count>
    <who name="Zacky Ma">zacky</who>
    <bug_when>2024-07-25 23:56:38 -0700</bug_when>
    <thetext>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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2049365</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-07-29 21:11:14 -0700</bug_when>
    <thetext>&lt;rdar://problem/132778602&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>