Should focus-induced scrolling respect the scroll-behavior property?




2 years ago
9 months ago


(Reporter: mstange, Unassigned)



Firefox Tracking Flags

(firefox48 affected)



(1 attachment)



2 years ago
Created attachment 8731787 [details]

If you change focus, we scroll the focused element into view. But this scroll does not seem to respect the specified scroll behavior. Should it?

One case in which this creates problems is if web pages want to redirect the focus scroll to a different location with a smooth scroll. What happens now is that the browser sync-scrolls to the location that it thinks the focused element is displayed at, and then JS gets a chance to handle the focus event and can start a smooth scroll to the actual location that it wants the browser to scroll to. But this smooth scroll will start at the position that the browser sync-scrolled to, not at the scroll position from before the focus change. This can look very bad.
For an example, see and try to tab through the elements.

Comment 1

2 years ago
I asked for spec input at .

Comment 2

9 months ago
CSSOM Spec says about scroll-behavior, :

> The scroll-behavior property specifies the scrolling behavior for a scrolling box, when scrolling happens due to navigation or CSSOM scrolling APIs. Any other scrolls, e.g. those that are performed by the user, are not affected by this property.

I think the "navigation" here includes both the sequential focus navigation triggered by pressing "tab" key and the navigation to a fragment.
In chrome, scroll-behavior works both types of the navigation.
But in firefox, it only works for the navigation to a fragment. You can test the case from here:
You need to log in before you can comment on or make changes to this bug.