Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-anchor-position-1] Scroll adjustment doesn't work for chain of anchor-positioned elements #9071

Closed
xiaochengh opened this issue Jul 15, 2023 · 2 comments

Comments

@xiaochengh
Copy link
Contributor

Consider a tree like

CB
+- scroller
|  +- anchor
+- abspos1
+- abspos2

where abspos1 is anchored to anchor, and abspos2 is anchored to abspos1

(test case available at https://jsfiddle.net/b1ycnpvL/)

When scrolling the scroller, the desired behavior is that both abspos elements should move. But currently only abspos1 moves.

This is because the current spec only considers scroll offsets applied directly by scrollers between CB and the anchor, then the snapshotted scroll offset for abspos2 is 0, which means there's no adjustment.

This issue is similar to #8448 that it's caused by non-scroll translations applied to the anchor. This issue, however, seems more severe because it breaks nested menus.

The proper fix is probably by making snapshotted scroll offset taking more offsets into account, including sticky position offsets and anchor position offsets applied to all ancestors of the anchor, all the way until the CB (exclusively).

The name "snapshotted scroll offset" still seems appropriate, though, because the extra offsets are still caused by scrolling.

@flackr
Copy link
Contributor

flackr commented Nov 7, 2023

This feels similar to nested sticky position. In particular, when you nest a sticky position element within another sticky position element it needs to take into account that it is being shifted by its ancestor sticky position element.

We handle this in chromium by tracking the nearest ancestor which has a dynamic (i.e. sticky position) offset and we always update those ancestors first, then when calculating the offset applied to the descendant, we first apply the ancestor offset.

In this case, it sounds a bit different in that abspos2 isn't normally shifted by abspos1, but the anchor constraint is so a similar approach should work.

This feels like an implementation issue more than a spec issue though, save for perhaps circular anchor positions, though I believe the anchor position spec already prevents this.

Note that both anchor and sticky probably need to be aware of each other in these offset calculations. E.g. a sticky descendant of an anchor pos element needs to know the anchor offset to know the adjusted sticky constraints.

@wangxianzhu
Copy link

Chrome change to support chained anchor-position has landed: https://chromium-review.googlesource.com/c/chromium/src/+/5274137. All tests are marked tentative. Is there a plan to update the spec?

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Apr 8, 2024
Per the spec issue:

w3c/csswg-drafts#9071

The tested behavior is being added to the spec.

Bug: 40947467
Change-Id: I4f14f8c828a68ee296641f6c4e78fac3cc54fd51
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Apr 9, 2024
Per the spec issue:

w3c/csswg-drafts#9071

The tested behavior is being added to the spec.

Bug: 40947467
Change-Id: I4f14f8c828a68ee296641f6c4e78fac3cc54fd51
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5437021
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1284204}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Apr 9, 2024
Per the spec issue:

w3c/csswg-drafts#9071

The tested behavior is being added to the spec.

Bug: 40947467
Change-Id: I4f14f8c828a68ee296641f6c4e78fac3cc54fd51
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5437021
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1284204}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Apr 15, 2024
…, a=testonly

Automatic update from web-platform-tests
Mark scroll chaining tests non-tentative

Per the spec issue:

w3c/csswg-drafts#9071

The tested behavior is being added to the spec.

Bug: 40947467
Change-Id: I4f14f8c828a68ee296641f6c4e78fac3cc54fd51
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5437021
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1284204}

--

wpt-commits: fc96c5033f17d7747464a8daa29b0be20532777a
wpt-pr: 45619
ErichDonGubler pushed a commit to ErichDonGubler/firefox that referenced this issue Apr 16, 2024
…, a=testonly

Automatic update from web-platform-tests
Mark scroll chaining tests non-tentative

Per the spec issue:

w3c/csswg-drafts#9071

The tested behavior is being added to the spec.

Bug: 40947467
Change-Id: I4f14f8c828a68ee296641f6c4e78fac3cc54fd51
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5437021
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1284204}

--

wpt-commits: fc96c5033f17d7747464a8daa29b0be20532777a
wpt-pr: 45619
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants