w3c / w3c/csswg-drafts

[css-scroll-anchoring-1] Anchor selection algorithm can lead to random results

Open
#4,124 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

css-scroll-anchoring-1
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

The way that https://drafts.csswg.org/css-scroll-anchoring/#anchoring-algorithm works is:

  1. Walk the child nodes of our scrollable thing.
  2. Stop when we find one that meets certain criteria.

The thing is, the algorithm doesn't say what order the child nodes are walked in. As far as I can tell, you can walk them forwards, backwards, or in any random order, and those would all be spec-compliant.

Note that just walking in DOM order from start to end may not be the right thing either; e.g. if the parent is a grid the earlier DOM kids may not be the thing you want to anchor at because they are further from the block start edge than later kids are.

@emilio @skobes

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the anchoring algorithm section in the linked CSS Scroll Anchoring specification and review the issue's concern about unspecified child-node traversal order. Determine and document a deterministic selection rule that accounts for layout position, then update the specification text once the Working Group agrees on the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
documentation, web-dev
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.