navigator: also track comments visible in viewport (#2482)

This commit is contained in:
soxa 2025-09-04 00:41:36 +02:00 committed by GitHub
parent 5f697f3434
commit a794b59b91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -62,10 +62,6 @@ export function useCommentsNavigator () {
window.requestAnimationFrame(() => { window.requestAnimationFrame(() => {
if (!commentRef?.current || !commentRef.current.isConnected) return if (!commentRef?.current || !commentRef.current.isConnected) return
// don't track this new comment if it's visible in the viewport
const rect = commentRef.current.getBoundingClientRect()
if (rect.top >= 0 && rect.bottom <= window.innerHeight) return
// dedupe // dedupe
const existing = commentRefs.current.some(item => item.ref.current === commentRef.current) const existing = commentRefs.current.some(item => item.ref.current === commentRef.current)
if (existing) return if (existing) return