<?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>51211</bug_id>
          
          <creation_ts>2010-12-16 13:35:28 -0800</creation_ts>
          <short_desc>bluring and focusing contentEditable region doesn&apos;t preserve cursor position</short_desc>
          <delta_ts>2017-07-18 08:29:39 -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>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>GoogleBug</keywords>
          <priority>P3</priority>
          <bug_severity>Minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nick Santos">nicksantos</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>adele</cc>
    
    <cc>ap</cc>
    
    <cc>darin</cc>
    
    <cc>enrica</cc>
    
    <cc>jparent</cc>
    
    <cc>kalman</cc>
    
    <cc>rniwa</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>323384</commentid>
    <comment_count>0</comment_count>
    <who name="Nick Santos">nicksantos</who>
    <bug_when>2010-12-16 13:35:28 -0800</bug_when>
    <thetext>Repro steps:
   1. Select text in a contentEditable area
   2. Click on a blank area of the document.
   3. Call focus() on the contentEditable area from JS

Expected behavior:
The cursor position should be preserved.
This is the behavior we see with textareas.

Actual behavior:
Chrome moves the cursor to the start of the region. Safari selects the region. Ojan says that Safari at trunk performs like Chrome.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>323387</commentid>
    <comment_count>1</comment_count>
      <attachid>76809</attachid>
    <who name="Nick Santos">nicksantos</who>
    <bug_when>2010-12-16 13:37:52 -0800</bug_when>
    <thetext>Created attachment 76809
An interactive demo for contentEditable cursor position</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>323391</commentid>
    <comment_count>2</comment_count>
    <who name="Nick Santos">nicksantos</who>
    <bug_when>2010-12-16 13:44:44 -0800</bug_when>
    <thetext>FWIW, this bug is a reduction of a problem in Google Spreadsheets. You can repro the problem like so:
1) Go to docs.google.com
2) Create a new spreadsheet.
3) double-click on cell A1 and type &quot;=SUM(&quot;
4) Click a blank region at the top of the page.
5) Click cell A2 on the grid.

Expected behavior
The contents of the cell become &quot;=SUM(A2&quot;

Actual behavior
The contents of the cell become &quot;A2=SUM(&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>323396</commentid>
    <comment_count>3</comment_count>
    <who name="Ojan Vafai">ojan</who>
    <bug_when>2010-12-16 13:47:55 -0800</bug_when>
    <thetext>The fix for this would be to maintain a selection when we blur the root editable node and reselect it when we focus the root editable node. We already do this for text inputs IIRC to make selectionStart/selectionEnd work. I think this makes sense to do for contentEditable as well. 

This is especially frustrating for web developers because there is no blur event that reliably fires before the selection is cleared.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>323397</commentid>
    <comment_count>4</comment_count>
    <who name="Ojan Vafai">ojan</who>
    <bug_when>2010-12-16 13:49:38 -0800</bug_when>
    <thetext>Another case where this causes problems is making keyboard accessible toolbars for rich-text areas. The toolbar needs focus to be keyboard accessible, but that clears the selection. So you have to store the selection before it&apos;s blurred. Right now, you have to capture all the places in your code that might blur the rich-text area.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>469479</commentid>
    <comment_count>5</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-09-19 10:15:40 -0700</bug_when>
    <thetext>See also: bug 42646, bug 68322.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>469486</commentid>
    <comment_count>6</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-09-19 10:21:09 -0700</bug_when>
    <thetext>Do Firefox and Internet Explorer implement a similar feature?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>473639</commentid>
    <comment_count>7</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-09-26 19:29:41 -0700</bug_when>
    <thetext>This is definitely not an easy bug to fix. It&apos;ll be challenging to keep the cache and the actual selection consistent.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>76809</attachid>
            <date>2010-12-16 13:37:52 -0800</date>
            <delta_ts>2010-12-16 13:37:52 -0800</delta_ts>
            <desc>An interactive demo for contentEditable cursor position </desc>
            <filename>contenteditablecursor.html</filename>
            <type>text/html</type>
            <size>1405</size>
            <attacher name="Nick Santos">nicksantos</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIEhUTUw+DQo8aHRtbD48aGVhZD4NCjxtZXRhIGh0dHAtZXF1aXY9ImNvbnRlbnQt
dHlwZSIgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PVVURi04Ij4NCg0KDQo8c2NyaXB0Pg0K
DQpmdW5jdGlvbiAkKGlkKSB7DQogIHJldHVybiBkb2N1bWVudC5nZXRFbGVtZW50QnlJZChpZCk7
DQp9DQoNCjwvc2NyaXB0Pg0KPC9oZWFkPjxib2R5IHN0eWxlPSJtYXJnaW4tdG9wOiA1ZW07Ij4N
Cg0KPGRpdiBzdHlsZT0iYm9yZGVyOiB0aGluIHNvbGlkIHJlZDsiIGlkPSJlZGl0b3IiIGNvbnRl
bnRlZGl0YWJsZT0idHJ1ZSI+DQpUaGlzIGlzIGFuIGNvbnRlbnRFZGl0YWJsZSByZWdpb24uDQo8
L2Rpdj48cD4NCg0KPGlucHV0IG9uY2xpY2s9IiQoJ2VkaXRvcicpLmZvY3VzKCk7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