Sphere
Log in Join
☆ 14

IntersectionObserver callback never fires in Safari 17

I have an infinite scroll list using IntersectionObserver on a sentinel div. Works in Chrome 125 and Firefox 126, but in Safari 17.4 the callback fires once on mount and then never again when the sentinel comes into view. rootMargin is 0px 0px 200px 0px, threshold 0. I am scrolling a container with overflow-y: auto, not the window. Do I need to pass root explicitly?

⚑ Report

4 replies

☆ 0
B bsod ·2026-10-18#1

Yes, if you are scrolling a container you must pass that container as root. If you omit it, the default is the viewport, and the sentinel is always in view relative to the viewport because the container clips it. Safari behaves differently here. Pass root: containerRef.current.

⚑ Report
☆ 0
L loot ·2026-10-20#2

Passing root fixed it. I also had the observer created before the container ref was attached to the DOM, so on first render root was null and it fell back to viewport again. Moved the observer creation into an effect that runs after mount.

⚑ Report
☆ 0
H hash ·2026-10-22#3

Also watch out: Safari has been stingy about observing elements with visibility: hidden or zero size. Make sure your sentinel actually has a height, even 1px. We used an empty div with no height and it behaved inconsistently across browsers.

⚑ Report
☆ 0
I inode ·2026-10-24#4

If it ever flakes again, a fallback scroll listener on the container comparing scrollTop + clientHeight >= scrollHeight - 200 is ugly but bulletproof. We keep it behind a Safari check. Not proud of it, but QA stopped complaining. It is not elegant, but it has held up across every browser we test.

⚑ Report
Log in to reply.