New issue
Advanced search Search tips

Issue 664246 link

Starred by 3 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

scrollIntoView or linking to a scroll anchor on a sticky element should scroll to the normal flow position.

Project Member Reported by flackr@chromium.org, Nov 10 2016

Issue description

Version: 56.0.2915.0
OS: All

We currently scroll to the current position of sticky elements when trying to scroll them into view. This matches Firefox and Safari, but I believe is not the desired behavior because scrolling to that sticky element can then move it such that scrolling to it again moves again. Additionally, sticky position top is often used at the beginning of section headers, it makes sense that scrolling to the section header should scroll to the top of the section.

I think we should instead scroll to the normal flow position of the sticky element as this is a stable anchor point and I think makes more sense for a lot of use cases.

I will add some motivating examples to demonstrate this.
 

Comment 1 by flackr@chromium.org, Nov 10 2016

For example, consider http://output.jsbin.com/qudira where you effectively have section headers with links to sections at the bottom of each. Currently, we never jump up because the section header is currently at the top of the viewport.

Comment 2 by bokan@chromium.org, Nov 10 2016

I agree that's probably the most useful use case. The counter-argument to me would be that we're changing the semantics of scrollIntoView based on positioning type which seems like it'd hurt platform predictability (admittedly minorly).

Perhaps adding an option in scrollIntoViewOptions maybe another approach? 
Cc: smcgruer@chromium.org
FYI there is also the example of http://output.jsbin.com/lukekot/15, where scrollIntoView() will increment the scroll offset to try and place the sticky at the top of the page. The sticky will then move to be properly offset for its constraints, and calling scrollIntoView() will increment the scroll offset again. Ad infinitum ;)

Comment 5 by flackr@chromium.org, Jan 23 2017

I'm not sure that this is all that different than scrollIntoView being a no-op on a fixed position element. The spec for scrollIntoView doesn't seem to make an exemption for fixed position (see https://drafts.csswg.org/cssom-view/#element-scrolling-members) which means that technically we should be attempting to scroll to its bounding client rect (like we currently do for sticky) even though scrolling to it means it will get pushed further down (which can also happen with sticky).

Of course I would like to see consistent behavior between browsers so it'd be great to standardize the stable scroll into view behavior for fixed and sticky position elements.

Comment 6 by flackr@chromium.org, May 23 2017

I filed https://github.com/w3c/csswg-drafts/issues/1459 to discuss changing this in the spec.

Sign in to add a comment