Skip to content

fix: onScrollEnd race condition breaking onValueChanged#77

Open
LouisHaftmann wants to merge 1 commit into
quidone:mainfrom
LouisHaftmann:main
Open

fix: onScrollEnd race condition breaking onValueChanged#77
LouisHaftmann wants to merge 1 commit into
quidone:mainfrom
LouisHaftmann:main

Conversation

@LouisHaftmann

@LouisHaftmann LouisHaftmann commented May 20, 2026

Copy link
Copy Markdown

Might fix #65 but didn't test it on web

Problem

onValueChanged is frequently not being triggered.

Cause

onScrollEnd is often not called when the onMomentumScrollEnd callback is triggered because the debounce is cancelled before running the onScrollEnd function. The debounce gets cancelled by the scroll offset listener which runs after onMomentumScrollEnd because react-native scrolls the container to snap to the selected item.

Fix

Check if the momentum scroll already ended inside the scroll offset listener and only clear the debounce if momentum scroll hasn't ended yet.

Possible new Problems

I don't think this will cause any new issues (not 100% sure) since the default behavior (even without onMomentumScrollBegin ever being called) is the same as before.

@rozhkovs

Copy link
Copy Markdown
Member

@LouisHaftmann Thanks for looking into this and opening the PR.

I don't have enough information about the issue yet. Could you please share more details: the platform/environment where you can reproduce it, a short video if possible, and logs showing the order in which the scroll callbacks/listeners are called?

@LouisHaftmann

Copy link
Copy Markdown
Author

I'll gather as much info as possible and come back to you

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.

onValueChanged not triggering on web

2 participants