fix(useInfiniteScroll): re-measure arrived states when async infinite scroll resolves #3030
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before submitting the PR, please make sure you do the following
fixes #123
).Description
Issue: #3019
Our
useInfiniteScroll
composable is not working with async functions. This is caused byarrivedState[direction]
never being set tofalse
when the container is resized.This state becomes stuck because the measurement of these values only happens during
onScrollHandler
, and so if the user is no longer scrolling, no re-measurement occurs and we enter the infinite loop.The simplest way to force a measurement is just to fire a scroll event ourselves, but this may not be the fix we want. We might want to let
useScroll
handle observation of it's height, but this would require a larger refactor. Let me know if that's the route we'd rather go and I'll make the changes.Another solution that might be a happy medium is for
useScroll
to return a function that can force a re-measurement. This might be the most flexible solution, because it would allow for measurements to happen for whatever reason we want 🤔Update: I've made the refactor to return a force-measurement function, I think I like this better, but let me know what you think! If we'd rather force the measurement by just firing a scroll event, we can revert 87d6757
Additional context
🤖 Generated by Copilot at e44a129
Fix initial load bug in
useInfiniteScroll
hook. Dispatch scroll event on observed element to trigger fetch function.🤖 Generated by Copilot at e44a129