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 11699 - When calling input.focus(), should (a) the cursor be at the start, (b) the cursor be at the end or (c) the contents be selected? Please define
Summary: When calling input.focus(), should (a) the cursor be at the start, (b) the cu...
Status: CLOSED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: LC1 HTML5 spec (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords: Disagree
Depends on:
Blocks:
 
Reported: 2011-01-08 16:20 UTC by contributor
Modified: 2011-08-04 05:34 UTC (History)
8 users (show)

See Also:


Attachments

Description contributor 2011-01-08 16:20:12 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html
Section: http://www.whatwg.org/specs/web-apps/current-work/#focus-management

Comment:
When calling input.focus(), should (a) the cursor be at the start, (b) the
cursor be at the end or (c) the contents be selected? Please define

Posted from: 91.181.240.75 by ms2ger@gmail.com
Comment 1 Mounir Lamouri 2011-01-24 16:10:04 UTC
I wonder if we couldn't let .focus() behavior be the one used by the system and require authors to use .setSelectionRange() if they need to cursor to be at a specific position?
Comment 2 Aryeh Gregor 2011-01-27 00:10:51 UTC
What's "the one used by the system" supposed to be?  Normally you'd focus things by clicking on them, which would place the cursor where you click.  So you mean what you'd get by alt-tabbing to it?  Do platforms actually differ on where the cursor goes then?  (Linux seems to select the contents.)
Comment 3 Mounir Lamouri 2011-01-27 15:30:10 UTC
(In reply to comment #2)
> So
> you mean what you'd get by alt-tabbing to it?  Do platforms actually differ on
> where the cursor goes then?  (Linux seems to select the contents.)

For example, yes. But the idea is it doesn't seem to be very useful to specify that given that an API is available to set the cursor wherever the author wants.
Comment 4 Aryeh Gregor 2011-01-27 19:08:44 UTC
I don't get what you're saying.  Surely it's always good to specify things exactly so that browsers are interoperable, even if there are clearer ways of doing the same thing?
Comment 5 Mounir Lamouri 2011-01-28 14:56:30 UTC
What I meant is it's better to request the UA to behave like the system usually behave to keep some consistency. If we do that, authors would not be able to [sanely] rely on a particular behavior but given that we have the selection API, it doesn't seem to be a big deal.
Comment 6 Aryeh Gregor 2011-01-28 21:07:55 UTC
Is platform consistency relevant to focus()?  Would users expect behavior of focus() to match the platform behavior of tabbing to the field?  That seems unlikely to me, unless it's being used specifically to emulate tabbing for some reason.
Comment 7 Mounir Lamouri 2011-01-29 23:31:04 UTC
Given that systems might have different behavior for that and the web platform has an API to override this behavior, it doesn't sound really important to force all UAs to have the same behavior on all platforms.
FWIW, a lot of things in focus management seems to be "do whatever the platform do".

Anyway, that's no big deal.
Comment 8 Ian 'Hixie' Hickson 2011-02-19 00:11:03 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: Partially Accepted
Change Description: see diff given below
Rationale: It's platform-specific, but I've explicitly called out where it has to happen if it happens.

(It has to be platform-specific, because users will complain if, e.g., tabbing to a field doesn't do the same thing as in other apps on their platform.)
Comment 9 contributor 2011-02-19 00:26:18 UTC
Checked in as WHATWG revision r5911.
Check-in comment: Define when the platform-specific focusing behavior happens relative to focus events, etc.
http://html5.org/tools/web-apps-tracker?from=5910&to=5911
Comment 10 Michael[tm] Smith 2011-08-04 05:34:12 UTC
mass-move component to LC1