Skip to content

fix(viewability): exclude items behind sticky header offset#2373

Open
codergon wants to merge 1 commit into
Shopify:mainfrom
codergon:fix/viewability-sticky-header-offset
Open

fix(viewability): exclude items behind sticky header offset#2373
codergon wants to merge 1 commit into
Shopify:mainfrom
codergon:fix/viewability-sticky-header-offset

Conversation

@codergon

@codergon codergon commented Jul 8, 2026

Copy link
Copy Markdown

Description

Fixes #2238

When there is a fixed header on top of the list, you can set stickyHeaderConfig.offset so sticky headers stop below it. That offset marks the area covered at the top of the list, but viewability was ignoring it, so items scrolled behind the header were still reported by onViewableItemsChanged.

This passes the same offset into the viewability check. The visible area now starts at offset instead of 0, so rows hidden behind the header are no longer counted as viewable, and partial visibility is measured against the area below the offset. Nothing changes when no offset is set, since it defaults to 0.

Reviewers' hat-rack:

  • ViewabilityHelper.isItemViewable clamps the top of the visible area to the offset and divides viewAreaCoveragePercentThreshold by the height below it
  • ViewabilityManager reads stickyHeaderConfig.offset and passes it through
  • Behavior is unchanged when no offset is set, covered by the existing tests

Screenshots or videos (if needed)

List scrolled so a row sits behind a 120px fixed header. Before, that row is still reported viewable. After, it is excluded.

Before After
Before: with no offset, rows behind the header are still reported as viewable After: with the offset set, rows behind the header are excluded from viewable items

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

viewableItems not working correctly with an absolute header

1 participant