<?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>112968</bug_id>
          
          <creation_ts>2013-03-21 14:44:22 -0700</creation_ts>
          <short_desc>FKA: mouse click on buttons causes focus (document.activeElement) to be lost</short_desc>
          <delta_ts>2023-11-07 20:09:42 -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>Accessibility</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=22261</see_also>
          <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>0</everconfirmed>
          <reporter name="James Craig">jcraig</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cfleizach</cc>
    
    <cc>fotis.papadogeorgopoulos</cc>
    
    <cc>gsnedders</cc>
    
    <cc>jcraig</cc>
    
    <cc>me</cc>
    
    <cc>ntim</cc>
    
    <cc>rego</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>webkit</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>860718</commentid>
    <comment_count>0</comment_count>
    <who name="James Craig">jcraig</who>
    <bug_when>2013-03-21 14:44:22 -0700</bug_when>
    <thetext>REPRO *
1. Load attached test case.
2. Tab so that focus is on one of the buttons.
3. Perform a mouse click on the same button. (Notice focus ring disappears.)
4. Press Tab again. (focus has been lost and resets to the beginning of the document)

Note: It&apos;s probably okay to &quot;hide&quot; the focus pseudo-state when switching to a mouse, but Tabbing should cause focus to come back to the same element rather than losing document.activeElement entirely.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>860730</commentid>
    <comment_count>1</comment_count>
      <attachid>194349</attachid>
    <who name="James Craig">jcraig</who>
    <bug_when>2013-03-21 14:47:19 -0700</bug_when>
    <thetext>Created attachment 194349
test case demonstrating bug</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>860734</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2013-03-21 14:48:14 -0700</bug_when>
    <thetext>&lt;rdar://problem/13477257&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>860735</commentid>
    <comment_count>3</comment_count>
    <who name="James Craig">jcraig</who>
    <bug_when>2013-03-21 14:48:42 -0700</bug_when>
    <thetext>See expected behavior in Firefox 19 for Mac.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>860736</commentid>
    <comment_count>4</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2013-03-21 14:49:02 -0700</bug_when>
    <thetext>&lt;rdar://problem/13477269&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>861923</commentid>
    <comment_count>5</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2013-03-22 15:51:21 -0700</bug_when>
    <thetext>See also: bug 22261.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1076572</commentid>
    <comment_count>6</comment_count>
    <who name="James Craig">jcraig</who>
    <bug_when>2015-03-11 23:20:37 -0700</bug_when>
    <thetext>&lt;rdar://problem/13477257&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1449064</commentid>
    <comment_count>7</comment_count>
    <who name="Mu-An Chiou">me</who>
    <bug_when>2018-08-09 11:26:44 -0700</bug_when>
    <thetext>Any updates on this? I see that there&apos;s not been any changes since the bug was reported 5 years ago. This issue makes building custom widget with focus management very tricky.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1769497</commentid>
    <comment_count>8</comment_count>
    <who name="James Craig">jcraig</who>
    <bug_when>2021-06-14 12:08:19 -0700</bug_when>
    <thetext>Relating to the newer :focus-visible tracker in bug 225148</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1858709</commentid>
    <comment_count>9</comment_count>
    <who name="Manuel Rego Casasnovas">rego</who>
    <bug_when>2022-04-06 00:36:16 -0700</bug_when>
    <thetext>Very related bug, see bug #229895.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1977040</commentid>
    <comment_count>10</comment_count>
    <who name="Mu-An Chiou">me</who>
    <bug_when>2023-09-12 03:43:27 -0700</bug_when>
    <thetext>Just talked about this at TPAC with ntim and jcraig I just want to add to the repro steps:

REPRO *
1. Load attached test case.
2. Tab so that focus is on one of the buttons.
3. Perform a mouse click on the same button. (Notice focus ring disappears.)
4. Press Tab again. (focus has been lost and resets to the beginning of the document)

As of 16.6, step 4 is no longer the case. the next focus point does land on the button. However if you do `setInterval(() =&gt; console.log(document.activeElement), 1000)` to observe the current focused element, you would see that after step 3, the activeElement goes back to body.

nTim mentioned that there has been a recent fix to account for how button[tabindex=0] should be click-focusable like div[tabindex=0]. https://github.com/WebKit/WebKit/pull/12743

Now that :focus-visible is implemented, I wonder if WebKit would mind reconsidering this special treatment (https://github.com/WebKit/WebKit/blob/b38121da42a0483fdb1bc13782f1c7a8059de100/Source/WebCore/html/HTMLFormControlElement.cpp#L255C13-L255C13) to buttons?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1990707</commentid>
    <comment_count>11</comment_count>
    <who name="James Craig">jcraig</who>
    <bug_when>2023-11-07 18:24:47 -0800</bug_when>
    <thetext>Seems reasonable to me... When I filed this back in 2013, :focus-visible didn&apos;t exist so there wasn&apos;t a way to make this work for all use cases, but I think that wwide support of :focus-visible now unblocks this, right?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1990720</commentid>
    <comment_count>12</comment_count>
    <who name="James Craig">jcraig</who>
    <bug_when>2023-11-07 20:09:42 -0800</bug_when>
    <thetext>Seems fixed in latest STP so this was probably resolved along with :focus-visible. Muan, if you know of other instances where this doesn&apos;t work, will you open a new issue?</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>194349</attachid>
            <date>2013-03-21 14:47:19 -0700</date>
            <delta_ts>2013-03-21 14:47:19 -0700</delta_ts>
            <desc>test case demonstrating bug</desc>
            <filename>webkit_112968.html</filename>
            <type>text/html</type>
            <size>274</size>
            <attacher name="James Craig">jcraig</attacher>
            
              <data encoding="base64">PGh0bWw+CjxoZWFkPgoJPHRpdGxlPkZvY3VzIExvc3QgQnVnPC90aXRsZT4KPC9oZWFkPgo8Ym9k
eT4KCTxidXR0b24+Rm9vPC9idXR0b24+Cgk8YnV0dG9uPkJhcjwvYnV0dG9uPgoJPGJ1dHRvbj5C
YXo8L2J1dHRvbj4KCTxidXR0b24+Qm9wPC9idXR0b24+Cgk8YnV0dG9uPkJpZjwvYnV0dG9uPgoJ
PGJ1dHRvbj5CYXA8L2J1dHRvbj4KCTxidXR0b24+Rml6PC9idXR0b24+Cgk8YnV0dG9uPkZ1ejwv
YnV0dG9uPgoJPGJ1dHRvbj5GdW48L2J1dHRvbj4KPC9ib2R5Pgo8L2h0bWw+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>