Fix projection of fixed elements when scrolling #2647
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes the failing
position: fixed;
projection tests added in #1768.Fixes issues #2514, #2006, and #1972.
Details
To handle projecting fixed elements within scrollable pages: as I understand it, the existing logic accounted for scroll root ancestors within
removeElementScroll
by iterating over thepath
, but this didn't account for the case where the current element was a fixed element, because thepath
does not contain the current node. Instead, we now avoid adding the scroll position inmeasurePageBox
when the projection is or is within a fixed element.To handle projected fixed elements within scrollable elements: this was a similar case where we weren't accounting for the current element's scroll information. If the current element is fixed, we can return early from
removeElementScroll
.To handle projecting when an element changes between fixed and static positions: we track whether the position was fixed during the snapshot phase (instead of relying on the most recently measured value) and use that to determine whether the projection considers an element fixed or not. Two considerations here:
position: sticky;
andposition: fixed;
. Fixing this may involve tracking more than just whether or not the element is fixed when the snapshot is taken; I haven't spent enough time with that failing test case.