<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26907</bug_id>
          
          <creation_ts>2014-09-25 23:25:58 +0000</creation_ts>
          <short_desc>Spec for reference fragment navigation to a non-focusable element does not match reality</short_desc>
          <delta_ts>2014-11-07 01:09:48 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>rob</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>ian</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>112222</commentid>
    <comment_count>0</comment_count>
      <attachid>1518</attachid>
    <who name="">rob</who>
    <bug_when>2014-09-25 23:25:58 +0000</bug_when>
    <thetext>Created attachment 1518
Test case for checking the focus behavior upon a reference fragment navigation

The HTML5 specification defines the algorithm for reference fragment navigation at https://html.spec.whatwg.org/multipage/browsers.html#scroll-to-fragid.

In short:
- If the reference fragment refers to an element, scroll this target element into view.
- If the target is non-focusable, abort these steps.
- If the target is focusable, focus the element (https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps)

It turns out that this behavior does not match the behavior of the web browsers.
Visit https://robwu.nl/s/chromium/bug417636/focus-navigation-test.html and try to focus each of the fields labeled &quot;onfocus = ...&quot;. Upon focus, the document is assigned a new reference fragment.

Test subjects:
- Firefox 3.6, 11, 32
- IE 8, 9, 10, 11
- Chrome 34, 39
- Safari 6, 6.1, 7, 8
( Opera 12.15 and Safari 5.1 also tested but not mentioned below because they do not change the focus under any circumstances )

When the target is focusable, the behavior is quite consistent:
- Firefox assigns the focus to the target (:focus is not applied, but sequential focus navigation [HTML5 6.4.5] takes the target as the starting point - https://bugzilla.mozilla.org/show_bug.cgi?id=308064).
- IE, Chrome and Safari focuses the target.

When the target is NON-focusable:
- Firefox behaves identical to the case when the target is focusable.
- IE focuses the non-focusable element (a caret briefly appears then disappears).
- Chrome and Safari: The focus does not change.

Before I continue, a bit more about the background that lead to me reporting this issue. WebKit never supported a:focus. When I added a:focus support to Chrome 39, a visual regression was reported at https://crbug.com/417636. This bug was caused by the fact that Chrome does not focus a non-focusable element after a reference fragment navigation (which is exactly what the current specification requires (non-focusable =&gt; abort steps)).

The behavior of Firefox and IE are mutually consistent, and I believe that Blink and WebKit should match their behavior as well. Otherwise implementing a:focus in the Blink/WebKit will lead to visual results that differ from Firefox/IE.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112940</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-10-10 04:11:59 +0000</bug_when>
    <thetext>It seems like the way to fix this that is sane is to make it move the focus to the viewport, not making it move the focus to the element. That would be consistent with the non-focusable element not matching :focus and activeElement returning the body.

Note that what Firefox does is move the invisible caret as well. That&apos;s a different issue than what has focus. (Fit F7 in Firefox to see this working more explicitly, IIRC.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112942</commentid>
    <comment_count>2</comment_count>
    <who name="">rob</who>
    <bug_when>2014-10-10 08:53:12 +0000</bug_when>
    <thetext>Hi Ian, that sounds like the most widely acceptable solution. That behavior has been implemented in Blink in the past week: http://src.chromium.org/viewvc/blink?view=revision&amp;revision=183455

The other issue is different, and only Firefox seems to behave in that way. It is however superior over the current implementations in IE/Blink, and also viewed as a desirable feature in Chrome: https://code.google.com/p/chromium/issues/detail?id=262171. The relevant specification [SFN] does not take non-focusable elements into account, so the discrepancy in implementations is not surprising.

[SFN] https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112964</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-10-10 17:59:52 +0000</bug_when>
    <thetext>Ah, yeah, making sequential focus navigation sensitive to more than just the currently focused node would make sense. Can you file a new bug for that? Thanks.
   https://whatwg.org/newbug</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114626</commentid>
    <comment_count>4</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-11-07 01:09:48 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8845.
Check-in comment: Define how focus sequential navigation works in slightly more detail; make navigating to an unfocusable control lead to the viewport being refocused.
https://html5.org/tools/web-apps-tracker?from=8844&amp;to=8845</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>1518</attachid>
            <date>2014-09-25 23:25:58 +0000</date>
            <delta_ts>2014-09-25 23:25:58 +0000</delta_ts>
            <desc>Test case for checking the focus behavior upon a reference fragment navigation</desc>
            <filename>focus-navigation-test.html</filename>
            <type>text/html</type>
            <size>1776</size>
            <attacher>rob</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxoZWFkPgo8c3R5bGU+CmxhYmVsIHsKICAgIGRpc3BsYXk6IGJsb2Nr
OwogICAgbWFyZ2luOiAxZW07Cn0KaW5wdXQgewogICAgd2lkdGg6IDgwJTsKfQouZm9jdXNlZCB7
CiAgICBiYWNrZ3JvdW5kOiAjRUVFCn0KPC9zdHlsZT4KPC9oZWFkPgo8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