<?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>112854</bug_id>
          
          <creation_ts>2013-03-20 16:22:35 -0700</creation_ts>
          <short_desc>contenteditable element does not completely surrender focus</short_desc>
          <delta_ts>2024-11-16 15:52:52 -0800</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>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>UNCONFIRMED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc>http://jsfiddle.net/A9QXk/</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>HasReduction, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>38696</dependson>
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Jared Jacobs">jmjacobs</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>jcraig</cc>
    
    <cc>jmjacobs</cc>
    
    <cc>megan_gardner</cc>
    
    <cc>ntim</cc>
    
    <cc>rniwa</cc>
    
    <cc>sarahmhigley</cc>
    
    <cc>vepomoc</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>859843</commentid>
    <comment_count>0</comment_count>
    <who name="Jared Jacobs">jmjacobs</who>
    <bug_when>2013-03-20 16:22:35 -0700</bug_when>
    <thetext>To reproduce the problem:
1. Type in a contenteditable element.
2. Click outside the contenteditable element on a focusable control that does not support text entry (e.g. a button).
3. Type an &quot;x&quot;.

The blinking caret is still in the editable element after step 2, even though focus had left it. The blinking caret should have been gone.

After step 3, an &quot;x&quot; was added to the editable box and it had reclaimed focus. Neither of those things should have happened.

I have witnessed the bug on the webkit nightly at SVN r146339. The bug has affected Safari and Chrome for years.

Here is a workaround, dated July 2011:
https://gist.github.com/1081133
It&apos;s the top web search result for &quot;webkit contenteditable workaround&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1654484</commentid>
    <comment_count>1</comment_count>
    <who name="Comandeer">vepomoc</who>
    <bug_when>2020-05-20 09:44:18 -0700</bug_when>
    <thetext>I can confirm that the issue is still present. We&apos;ve encountered it recently in CKEditor 4: https://github.com/ckeditor/ckeditor4/pull/3898#pullrequestreview-388090174.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1655028</commentid>
    <comment_count>2</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2020-05-21 12:05:39 -0700</bug_when>
    <thetext>Ah, this is because selection &amp; focus behavior in WebKit matches macOS convention unlike other browsers. In WebKit, focus moves to where selection is whereas in other browsers, selection moves to where focus is. This is more or less expected behavior from that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1873288</commentid>
    <comment_count>3</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-06-01 06:11:40 -0700</bug_when>
    <thetext>I am able to reproduce this bug in Safari 15.5 and other browsers (Chrome Canary 104 and Firefox Nightly 103) behave same and different from Safari 15.5 and matches expected results. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2075220</commentid>
    <comment_count>4</comment_count>
    <who name="Sarah Higley">sarahmhigley</who>
    <bug_when>2024-11-14 15:43:34 -0800</bug_when>
    <thetext>This seems a little more complex (and more clearly broken) than selection not following focus. Clicking a button or link to blur a contenteditable will change how subsequent key presses are processed in that contenteditable when it regains focus.

Clicking a button or link also does not match what happens when you click the background page / non-interactive content, even though both will blur the contenteditable and reset document.activeElement to the body.

There are a couple other weird side effects going on here. I made a codepen to demonstrate what I&apos;ve found, that lists them: https://codepen.io/smhigley/pen/oNKVyMo</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2075585</commentid>
    <comment_count>5</comment_count>
    <who name="James Craig">jcraig</who>
    <bug_when>2024-11-16 15:51:31 -0800</bug_when>
    <thetext>Agreed that there is unexpected behavior here. Sarah’s codepen illustrates it well. Thanks Sarah.

The document caret position doesn’t get moved with focus. Even if you’ve tabbed past the content editable region, subsequent arrow key events are still unexpectedly sent back to the content editable. 

This behavior: 

1. Breaks the WebKit/Safari expectation that arrows could be used for scrolling here, and…
2. Pulls focus back unexpectedly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2075586</commentid>
    <comment_count>6</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-11-16 15:52:52 -0800</bug_when>
    <thetext>&lt;rdar://problem/140048563&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>