Skip to content

fix(v-intersect): auto-detect scrollable ancestor as root#22844

Open
VaishnaviD5900 wants to merge 2 commits intovuetifyjs:masterfrom
VaishnaviD5900:fix/vtimeline-intersect-root-null
Open

fix(v-intersect): auto-detect scrollable ancestor as root#22844
VaishnaviD5900 wants to merge 2 commits intovuetifyjs:masterfrom
VaishnaviD5900:fix/vtimeline-intersect-root-null

Conversation

@VaishnaviD5900
Copy link
Copy Markdown
Contributor

Description

Fixes #22147

When using v-intersect on a VTimelineItem (or any element inside
a scrollable container), the IntersectionObserver root was always null,
causing it to use the viewport instead of the nearest scrollable ancestor.

Root Cause

The mounted function in the intersect directive created the
IntersectionObserver with empty options {}, defaulting root to null.
Additionally, the DOM wasn't fully available at mount time.

Fix

  • Added getScrollableAncestor() helper that walks up the DOM to find
    the nearest scrollable ancestor
  • Wrapped observer creation in nextTick to ensure DOM is fully mounted
  • When no explicit root is provided, auto-detect the nearest scrollable
    ancestor as the root

How to Test

  1. Place v-intersect on a VTimelineItem inside a scrollable container
  2. Verify observer.root is the scrollable container, not null
  3. Verify isIntersecting correctly reflects visibility within the container

Closes

Closes #22147

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report][3.10.4] VTimelineItem with v-intersect directive has IntersectionObserver root as null in VTimeline

1 participant