<?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>213982</bug_id>
          
          <creation_ts>2020-07-05 20:29:09 -0700</creation_ts>
          <short_desc>WebKit autofocuses the last available autofocus element instead of the first available</short_desc>
          <delta_ts>2020-09-26 15:25:25 -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>Forms</component>
          <version>Other</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>203139</dup_id>
          
          <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="Maciej Stachowiak">mjs</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cdumez</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>1668966</commentid>
    <comment_count>0</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2020-07-05 20:29:09 -0700</bug_when>
    <thetext>WebKit autofocuses the last available autofocus element instead of the first available. Other browsers autofocus the first. 

Here is a test case: https://mehdi.cc/tests/multiple-autofocus/

In Safari, this focuses Field 2. In Firefox and Chrome, Field 1.

The spec says to autofocus the first. Well, sort of... autofocus for purposes of page load focus is only considered at element insertion time, not when the attribute is added or removed; and it&apos;s not the first element in document order that wins, it&apos;s the first (eligible) to be inserted.


Full spec details are here: https://html.spec.whatwg.org/#the-autofocus-attribute</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1668967</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2020-07-05 20:29:28 -0700</bug_when>
    <thetext>&lt;rdar://problem/65116588&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1692231</commentid>
    <comment_count>2</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2020-09-26 15:25:25 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 203139 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>