Repository navigation
Don't report IntersectionObserver targets fully clipped by an ancestor as intersecting - #60152
Merged
meta-codesync[bot] merged 1 commit intoNov 19, 2026
Conversation
Summary:
When an ancestor between the target and the root (a ScrollView or an
`overflow: hidden` view) clips the target away entirely,
`getClippedTargetBoundingRect` returned `Rect{}`: a zero-size rect at the
origin. `intersectOrNull` then treated that as an edge-adjacent intersection
whenever the root rectangle contained the origin, which is always the case
for the implicit root (the origin is its corner) and almost always for an
explicit root (the empty rect is translated to the root's origin).
Because a threshold of 0 is crossed by an intersection ratio of 0, observers
with the default `threshold` (or an `rnRootThreshold` containing 0) reported
such targets with `isIntersecting: true`, as long as their unclipped bounding
box overlapped the root. `rootMargin` makes this easy to hit, since it widens
that overlap: e.g. with `rootMargin: '500px 0px'`, every item of a ScrollView
within 500px of the viewport is reported as intersecting even though the
ScrollView clips it.
A fully clipped target now produces no intersection, so it's reported as not
intersecting with an empty `intersectionRect`. This matches the
`intersection-observer/clip-path.html` Web Platform Test, where a target
fully clipped by an ancestor while its bounding box is inside the viewport
expects `isIntersecting: false`. Observers with thresholds above 0 are
unaffected: they already reported these targets as not intersecting, with
the same entry values.
Changelog:
[GENERAL] [FIXED] - IntersectionObserver no longer reports targets fully clipped by an ancestor as intersecting
Test Plan:
New Fantom tests cover a target fully clipped by an intermediate ScrollView
with the default threshold, and with `rootMargin`. Both fail without this
change.
|
@rubennorte has imported this pull request. If you are a Meta employee, you can view this in D133249484. |
javache
approved these changes
Nov 19, 2026
javache
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Collaborator
|
This pull request was successfully merged by @rubennorte in 8771d39 When will my fix make it into a release? | How to file a pick request? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary:
When an ancestor between the target and the root (a
ScrollViewor anoverflow: hiddenview) clips the target away entirely,getClippedTargetBoundingRectreturnedRect{}: a zero-size rect at the origin.intersectOrNullthen treated that as an edge-adjacent intersection whenever the root rectangle contained the origin. That's always the case for the implicit root (the origin is its corner), and almost always for an explicit root (the empty rect is translated to the root's origin).Because an intersection ratio of 0 crosses a threshold of 0, observers with the default
threshold(or anrnRootThresholdcontaining 0) reported these targets withisIntersecting: true, as long as their unclipped bounding box overlapped the root.rootMarginmakes this easy to hit because it widens that overlap. For example, withrootMargin: '500px 0px', every item of aScrollViewwithin 500px of the viewport is reported as intersecting, even though theScrollViewclips it.A fully clipped target now produces no intersection, so it's reported as not intersecting with an empty
intersectionRect. This matches theintersection-observer/clip-path.htmlWeb Platform Test: a target fully clipped by an ancestor, while its bounding box is still inside the viewport, expectsisIntersecting: false.Observers with thresholds above 0 are unaffected. They already reported these targets as not intersecting, with the same entry values.
Found while working on
scrollMarginsupport, which is stacked on top of this.Changelog:
[GENERAL] [FIXED] - IntersectionObserver no longer reports targets fully clipped by an ancestor as intersecting
Test Plan:
Added Fantom tests for a target fully clipped by an intermediate
ScrollView, with the default threshold and withrootMargin. Both fail without this change.110 passed, 1 skipped.
Clean.