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 9547 - If more than one element has the autofocus attribute specified, only the first one should be focused
Summary: If more than one element has the autofocus attribute specified, only the firs...
Status: CLOSED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: pre-LC1 HTML5 spec (editor: Ian Hickson) (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL: http://dev.w3.org/html5/spec/forms.ht...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-17 15:35 UTC by Mounir Lamouri
Modified: 2010-10-04 13:58 UTC (History)
7 users (show)

See Also:


Attachments

Description Mounir Lamouri 2010-04-17 15:35:05 UTC
At the moment, the autofocus attribute specification say only one element in the document should have the autofocus attribute specified but each time an element with the autofocus attribute is inserted into the document, it should be focused following the given rules. In other words, only one element should have the autofocus attribute specified and the last one will have the autofocus applying if there are more than one.

It would be probably better to have the exact opposite behavior: only the first element with the autofocus attribute specified should have the autofocus behavior applying. For the author, having more than one element with the autofocus attribute is already wrong and for the user it would be better.
For example:
<html>
  <body>
    <form>
      <input id=c1 autofocus>
    </form>
    ...lots of content here...
    <form>
      <input id=c2 autofocus>
    </form>
  </body>
</html>
The user will have the focus on the first input element and then the second input element will be focused. This may be really annoying. The specifications already said the autofocus may be ignored if the user has began to interact with the document. This can be done by not autofocusing when an element is already focused but it's would be a violation of the current specifications.

The change could be made in two ways:
- only the first focusable element with autofocus specified should be focused, or
- the autofocus attribute apply only if there is no focused element in the document.
Comment 1 Ian 'Hixie' Hickson 2010-08-16 22:15:19 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: More or less as requested.
Rationale: This was addressed as part of some e-mailed feedback recently.