Intent to implement and ship: add `preventScroll` option to HTMLElement's, SVGElement's and XULElement's `focus` method

149 views
Skip to first unread message

Mirko Brodesser

unread,
Apr 11, 2019, 10:34:30 AM4/11/19
to dev-pl...@lists.mozilla.org
*Summary*: this allows web-developers to focus an element without scrolling
to it.

*Bug*: https://bugzilla.mozilla.org/show_bug.cgi?id=1374045

*Link to standard*:
https://html.spec.whatwg.org/#dom-focusoptions-preventscroll

*Platform coverage*: all platforms.

*Estimated or target release*: Firefox 68.

*Preference behind which this will be implemented*: not applicable.

*Is this feature enabled by default in sandboxed iframes?* No and there's
no new sandbox flag to enable it.

*DevTools bug*: none.

*Do other browser engines implement this?* Shipped in Chrome (since version
64).

*web-platform-tests*:
http://w3c-test.org/html/interaction/focus/processing-model/preventScroll.html

*Is this feature restricted to secure contexts?* No.

*How stable is the spec: *it seems stable, apart from the special case of
re-focusing an element: https://github.com/whatwg/html/issues/4512.

*Example:* data:text/html,<style> input { margin-top: 40cm } </style>
<input type="text" id="i1"> <script> document.getElementById("i1").focus({
preventScroll: true }); </script>

The feature is planned to be shipped with Firefox 68. Chrome has already
shipped it.

*Bug to turn on by default*:
https://bugzilla.mozilla.org/show_bug.cgi?id=1374045

If there are questions or suggestions, please let me know.

sime....@gmail.com

unread,
Apr 12, 2019, 11:50:17 PM4/12/19
to
The multiplage version of the spec (for folks with slower machines):

https://html.spec.whatwg.org/multipage/interaction.html#dom-focusoptions-preventscroll

Makoto Kato

unread,
Apr 15, 2019, 3:21:57 AM4/15/19
to Mirko Brodesser, dev-platform
Hi, Mirko. (I mistake email address. sorry)

Does this work on GeckoView/Android too? When showing software keyboard,
web page may be scrolled without focus manager.

-- Makoto

On Thu, Apr 11, 2019 at 11:35 PM Mirko Brodesser <mbrod...@mozilla.com>
wrote:
> _______________________________________________
> dev-platform mailing list
> dev-pl...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
>

mbrod...@mozilla.com

unread,
Apr 16, 2019, 4:35:39 AM4/16/19
to
On Monday, April 15, 2019 at 9:21:57 AM UTC+2, Makoto Kato wrote:
> Hi, Mirko. (I mistake email address. sorry)
>
> Does this work on GeckoView/Android too? When showing software keyboard,
> web page may be scrolled without focus manager.

For the record: GeckoView will need to be adapted separately. There's https://bugzilla.mozilla.org/show_bug.cgi?id=1544660 to achieve this.
Reply all
Reply to author
Forward
0 new messages