Open Bug 1257600 Opened 8 years ago Updated 2 years ago

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

Categories

(Core :: Layout, defect)

defect

Tracking

()

Tracking Status
firefox48 --- affected

People

(Reporter: mstange, Unassigned)

References

Details

Attachments

(1 file)

Attached file testcase
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 https://output.jsbin.com/pubeluvumu/1 and try to tab through the elements.
I asked for spec input at https://github.com/whatwg/html/issues/94 .
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: https://jihyerish.github.io/scroll-with-focus/
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: