Skip to content

Commit

Permalink
Merge pull request #27076 from bernhardoj/fix/26723-waypoints-scroll-…
Browse files Browse the repository at this point in the history
…to-bottom

Fix scroll to bottom when number of waypoints increases don't work properly
  • Loading branch information
arosiclair authored Sep 12, 2023
2 parents 2163c54 + c67e816 commit 92bdd0d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/DistanceRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken})
Transaction.getRoute(iou.transactionID, validatedWaypoints);
}, [shouldFetchRoute, iou.transactionID, validatedWaypoints, isOffline]);

useEffect(() => {
if (numberOfWaypoints <= numberOfPreviousWaypoints) {
return;
}
scrollViewRef.current.scrollToEnd({animated: true});
}, [numberOfPreviousWaypoints, numberOfWaypoints]);

useEffect(updateGradientVisibility, [scrollContainerHeight, scrollContentHeight]);

return (
Expand All @@ -170,12 +177,7 @@ function DistanceRequest({iou, iouType, report, transaction, mapboxAccessToken})
onLayout={(event = {}) => setScrollContainerHeight(lodashGet(event, 'nativeEvent.layout.height', 0))}
>
<ScrollView
onContentSizeChange={(width, height) => {
if (scrollContentHeight < height && numberOfWaypoints > numberOfPreviousWaypoints) {
scrollViewRef.current.scrollToEnd({animated: true});
}
setScrollContentHeight(height);
}}
onContentSizeChange={(width, height) => setScrollContentHeight(height)}
onScroll={updateGradientVisibility}
scrollEventThrottle={variables.distanceScrollEventThrottle}
ref={scrollViewRef}
Expand Down

0 comments on commit 92bdd0d

Please sign in to comment.