<?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>93760</bug_id>
          
          <creation_ts>2012-08-10 21:08:08 -0700</creation_ts>
          <short_desc>Selection change caused by click event on button should be *after* the onclick fires</short_desc>
          <delta_ts>2022-07-26 22:50:13 -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>Mac (Intel)</rep_platform>
          <op_sys>OS X 10.8</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Gatwood">dgatwood</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>bfulgham</cc>
    
    <cc>rniwa</cc>
    
    <cc>tonikitoo</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>693046</commentid>
    <comment_count>0</comment_count>
      <attachid>157856</attachid>
    <who name="David Gatwood">dgatwood</who>
    <bug_when>2012-08-10 21:08:08 -0700</bug_when>
    <thetext>Created attachment 157856
Demonstrates odd behavior of buttons inside contentEditable regions

I would normally expect a button&apos;s onclick handler to fire prior to any in-browser modification of the current DOM selection.  For some odd reason, in WebKit, the reverse occurs—the selection changes first—leading to spectacular misbehavior if you&apos;re crazy enough to place a button inside a contentEditable region.  :-)

Test case attached.  The expected behavior is that when you click inside the text above, then click the button, the click event should fire first, causing the content to be inserted at the selection point.  Instead, the insertion point moves first, so that the insertion point is inside the text of the button.  Thus, the content gets inserted inside the button.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>693761</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2012-08-13 09:56:57 -0700</bug_when>
    <thetext>See also: bug 93674. Perhaps we match IE here, as well?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>694122</commentid>
    <comment_count>2</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-08-13 14:53:45 -0700</bug_when>
    <thetext>IE doesn&apos;t change the selection until click event either.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886921</commentid>
    <comment_count>3</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-07-26 15:05:25 -0700</bug_when>
    <thetext>I am able to reproduce this bug using attached test case in Safari 15.6 on macOS 12.5 where placing caret on the text and then pressing button trigger dialog with &quot;fail&quot; rather than adding text. It is same with Chrome Canary 106 and only Firefox Nightly 104 is where it add text and does not show any &quot;fail&quot; dialog. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886969</commentid>
    <comment_count>4</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-07-26 19:40:16 -0700</bug_when>
    <thetext>&lt;rdar://problem/97641753&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1887015</commentid>
    <comment_count>5</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-07-26 22:50:13 -0700</bug_when>
    <thetext>Blink and WebKit still fail the attached test case.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>157856</attachid>
            <date>2012-08-10 21:08:08 -0700</date>
            <delta_ts>2012-08-10 21:08:08 -0700</delta_ts>
            <desc>Demonstrates odd behavior of buttons inside contentEditable regions</desc>
            <filename>inserthtmlWrongPlace2.html</filename>
            <type>text/html</type>
            <size>613</size>
            <attacher name="David Gatwood">dgatwood</attacher>
            
              <data encoding="base64">PGh0bWw+CjxoZWFkPgo8c2NyaXB0IHR5cGU9InRleHQvamF2YXNjcmlwdCI+PCEtLQoKZnVuY3Rp
b24gdGVzdGl0KG91dGVyLCBpbm5lcikKewogICAgaWYgKCFkb2N1bWVudC5leGVjQ29tbWFuZCgi
aW5zZXJ0SFRNTCIsIGZhbHNlLCAiPHNwYW4gaWQ9J3Rlc3RzcGFuJz5BZGRlZCB0ZXh0PC9zcGFu
PiIpKSB7CglhbGVydCgiRXBpYyBmYWlsIik7CiAgICB9CgogICAgaWYgKGRvY3VtZW50LmdldEVs
ZW1lbnRCeUlkKCJteWJ1dHRvbiIpLmlubmVySFRNTCA9PSAiQ2xpY2sgdG8gYWRkIHRleHQgaW4g
dGhlIHRleHQgYWJvdmUuIikgewoJYWxlcnQoInBhc3MiKTsKICAgIH0gZWxzZSB7CglhbGVydCgi
ZmFpbCIpOwogICAgfQp9CgovLy0tPjwvc2NyaXB0Pgo8L2hlYWQ+Cjxib2R5IGNvbnRlbnRlZGl0
YWJsZT0idHJ1ZSI+Cgo8ZGl2IGlkPSJzY3JhdGNocGFkIj5QdXQgdGhlIGN1cnNvciBzb21ld2hl
cmUgaW4gdGhpcyB0ZXh0LCB0aGVuIGNsaWNrIHRoZSBidXR0b24gYmVsb3cuPC9kaXY+Cgo8YnV0
dG9uIGlkPSJteWJ1dHRvbiIgb25jbGljaz0idGVzdGl0KCk7Ij5DbGljayB0byBhZGQgdGV4dCBp
biB0aGUgdGV4dCBhYm92ZS48L2J1dHRvbj4KPC9ib2R5Pgo8L2h0bWw+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>