[csswg-drafts] [css-scroll-anchoring-1] Anchor selection should prefer 'active' nodes (#5018)

vmpstr has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-scroll-anchoring-1] Anchor selection should prefer 'active' nodes  ==
[Anchor selection algorithm](https://drafts.csswg.org/css-scroll-anchoring/#anchor-node-selection) only considers the DOM relationship of the nodes and their visibility in the scroller.

There are some situations where scroll initiated by a user-agent algorithm, such as find-in-page, causes us to select a suboptimal scroll anchor which pushes the find-in-page match outside of the viewport. 

This situation is possible if there is, for example, an intersection observer, which sizes on-screen elements differently from off-screen elements. When find-in-page match is scrolled to the center, we can pick a scroll anchor near the top of the viewport and after resizing and adjusting the scroll position end up in a situations where the find-in-page match is not visible.

One way to fix this is to prefer certain nodes in the anchor selection algorithm. Some potential interesting nodes (in no particular order) are the following:
- Find-in-page active match
- An element which was the target of scrollIntoView() "recently" (since the last anchoring adjustment?)
- An element with focus
- An element containing user selection

There may be more interesting nodes, or maybe some of the ones I listed are not as interesting, but I think the user-agents can use information other than DOM structure to select a nicer anchor

Any thoughts?

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5018 using your GitHub account

Received on Tuesday, 28 April 2020 15:27:00 UTC