Closed Bug 1374045 Opened 6 years ago Closed 5 years ago

Consider adding support for customizing scrolling behavior with Element.focus


(Core :: DOM: Core & HTML, enhancement, P3)




Tracking Status
firefox68 --- fixed


(Reporter: smaug, Assigned: mbrodesser-Igalia)


(Depends on 1 open bug)


(Keywords: dev-doc-complete)


(1 file)

There is no spec yet for this, so better to wait until there is, and then
review the spec carefully.
Priority: -- → P3
There is a spec proposal to disable automatic scroll into view on Element.focus().

Here is the summary of current situation:

The new dictionary type "FocusOptions" with the "preventScroll" dictionary member is introduced.

The IDL of Element.focus() will change to: 

dictionary FocusOptions {
  boolean preventScroll = false;
void focus(optional FocusOptions options);

If preventScroll is omitted or false, then the element will be scrolled into view with UA-defined manners.
Otherwise, it disables scrolling triggered by focus().

Very needed feature as preventScroll is extremely hard to implement properly on your own.

Component: DOM → DOM: Core & HTML
Assignee: nobody → mbrodesser
Ever confirmed: true

Filed a spec issue ( to avoid interoperability problems with Chrome and potentially clarify the spec for repeated re-focus events.

(Copying to here, because erroneously posted at the duplicate issue): Should be done for SVGElement too ( To keep the code simple we'll also add it to XULElement.

  • Remove expectation that 'preventScroll.html' fails.

  • Use '[NoInterfaceObject] interface' workaround to simulate missing 'mixin' support.

A try run corresponding to the review: There few failures are unrelated. Requesting check-in.

Tried to land this and received the following message: We're sorry, Autoland could not rebase your commits for you automatically. Please manually rebase your commits and try again. (255, 'applying /tmp/tmpzDM1eH\npatching file dom/html/HTMLLegendElement.cpp\nHunk #3 FAILED at 88\n1 out of 3 hunks FAILED -- saving rejects to file dom/html/HTMLLegendElement.cpp.rej\npatching file dom/html/HTMLLabelElement.cpp\nHunk #1 FAILED at 49\n1 out of 1 hunks FAILED -- saving rejects to file dom/html/HTMLLabelElement.cpp.rej\npatching file dom/base/Element.cpp\nHunk #1 FAILED at 337\n1 out of 1 hunks FAILED -- saving rejects to file dom/base/Element.cpp.rej\nabort: patch failed to apply', '')

Keywords: checkin-needed

Razvan: did you take the latest version of I had to resolve merge conflicts for the first version. I've just locally pulled and rebased without conflicts the latest version on:

commit 9dbbb9cb30e42518f410fb5b9968c7b178185748 (origin/branches/default/0b4aefa9f91cb941071c1fdb1c520188522bf710, origin/bookmarks/inbound, refs/cinnabar/refs/heads/branches/default/0b4aefa9f91cb941071c1fdb1c520188522bf710, refs/cinnabar/refs/heads/bookmarks/inbound)
Merge: 2782be40ae26 2ef7282d458b
Author: Ciure Andrei <>
Date:   Thu Apr 11 12:57:28 2019 +0300

    Merge mozilla-central to mozilla-inbound.  a=merge CLOSED TREE

Isn't the change cherry-picked on top of "origin/bookmarks/inbound"?

Flags: needinfo?(rmaries)

Phabricator lands patches on the top of autoland not inbound.

Flags: needinfo?(rmaries)

Razvan: I see. The merge-conflict stems from I'll look into it.

A try run corresponding to the review: The failures are unrelated to this change. Requesting check-in.

Pushed by
add 'preventScroll' option to HTMLElement's, SVGElement's and XULElement's 'focus' method r=smaug

Keywords: checkin-needed
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
Depends on: 1544660

Documentation updates:

  • While it already had most of this information, I have cleaned up and finished the changes to HTMLElement.focus()
  • Submitted BCD PR 4359 to add and update the info for SVGElement/HTMLElement focus() method and its options
You need to log in before you can comment on or make changes to this bug.