Skip to content

fix: respect waitForInteraction when initialScrollIndex is set#2130

Open
naqvitalha wants to merge 2 commits intomainfrom
fix/viewability-wait-for-interaction-initial-scroll
Open

fix: respect waitForInteraction when initialScrollIndex is set#2130
naqvitalha wants to merge 2 commits intomainfrom
fix/viewability-wait-for-interaction-initial-scroll

Conversation

@naqvitalha
Copy link
Collaborator

Summary

  • When initialScrollIndex is set, the programmatic scroll was calling recordInteraction(), bypassing waitForInteraction: true in viewability config and firing onViewableItemsChanged on mount
  • Moved initialScrollCompleted tracking from a local ref to isInitialScrollComplete on RecyclerViewManager
  • Gate recordInteraction() in the scroll handler behind isInitialScrollComplete so programmatic initial scrolls don't count as user interactions

Test plan

  • Unit tests: 2 new tests verifying callback doesn't fire on mount with waitForInteraction + initialScrollIndex, and does fire after real user interaction
  • All 183 existing tests pass (no regressions)
  • iOS simulator: Verified 0 calls on mount, callbacks fire after user scroll
  • Regression: Carousel (viewability) loads and scrolls normally
  • Regression: Horizontal List (initialScrollIndex=2) starts at correct item
  • Regression: Contacts list renders normally

Fixes #1943

When initialScrollIndex triggers a programmatic scroll, the scroll
handler was unconditionally calling recordInteraction(), which set
hasInteracted=true and bypassed the waitForInteraction gate in
viewability config. This caused onViewableItemsChanged to fire on
mount even when waitForInteraction was true.

Move the initialScrollCompleted tracking from a local ref to
isInitialScrollComplete on RecyclerViewManager, and gate
recordInteraction() behind it so programmatic initial scrolls
don't count as user interactions.

Fixes #1943
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.

onViewableItemsChanged is triggered when initialScrollIndex set

1 participant