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
Comments
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. |
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? |
Per the spec issue: w3c/csswg-drafts#9071 The tested behavior is being added to the spec. Bug: 40947467 Change-Id: I4f14f8c828a68ee296641f6c4e78fac3cc54fd51
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}
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}
…, 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
…, 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
Consider a tree like
where
abspos1
is anchored toanchor
, andabspos2
is anchored toabspos1
(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 forabspos2
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.
The text was updated successfully, but these errors were encountered: