This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 26725 - make element.focus() consider body element's focusable state for improved real-world interop
Summary: make element.focus() consider body element's focusable state for improved rea...
Status: RESOLVED MOVED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML5 spec (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P1 normal
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-03 18:20 UTC by Travis Leithead [MSFT]
Modified: 2016-04-27 22:18 UTC (History)
5 users (show)

See Also:


Attachments
Example showing the expectations of the new behavior; this is the primary repro file. (597 bytes, text/html)
2014-09-03 18:20 UTC, Travis Leithead [MSFT]
Details
Supporting Iframe (needed for the repro) (782 bytes, text/html)
2014-09-03 18:21 UTC, Travis Leithead [MSFT]
Details

Description Travis Leithead [MSFT] 2014-09-03 18:20:35 UTC
Created attachment 1508 [details]
Example showing the expectations of the new behavior; this is the primary repro file.

A few months ago, IE made a platform change to improve our Mobile interop to match a webkit behavior which a variety of sites required in order to display properly. The change involved the behavior of focusing the body element. IE [previously], Firefox, and the spec all define the behavior that when element.focus() is called on the body element, it forwards the focus command on to the window which causes the viewport to be in a focused state (this scenario is usually done from a parent browsing context calling focus() on the body element of a child browsing context). However, in Webkit-based browsers, the ability of the body/viewport to accept focus is conditional on whether the body element can actually accept focus (e.g., if the body element has a valid tabindex attribute set). So, in a webkit-based browser and now in IE (on mobile, soon to come to desktop) unless the body element is focusable the call to focus() the body will do nothing.

I recommend updating the spec to contain this condition in order to better match an interoperable pattern that many [mobile] sites expect. The change would be from:

> Section: Focus management APIs
>  element . focus()
>   Moves the focus to the element.
>   If the element is the body element, moves the focus to the viewport instead.

to:

> Section: Focus management APIs
>  element . focus()
>   Moves the focus to the element.
>   If the element is the body element, and the body element is focusable, moves the focus to the viewport instead. Otherwise, does nothing.

(and update the relevant details in the algorithm for the "focusing steps")
Comment 1 Travis Leithead [MSFT] 2014-09-03 18:21:49 UTC
Created attachment 1509 [details]
Supporting Iframe (needed for the repro)
Comment 2 Michael[tm] Smith 2015-06-16 10:22:29 UTC
Making this a higher priority to actively seek more feedback on from implementers and webdevs.
Comment 3 Arron Eicholz 2016-04-27 22:18:44 UTC
HTML5.1 Bugzilla Bug Triage: Moved to Github issue: https://github.com/w3c/html/issues/290

To file additional issues please use the W3C HTML5 Issue tracker: https://github.com/w3c/html/issues/new Thanks!