Skip to content

Commit

Permalink
List View: Fix scroll to top issue when dragging the second last bloc…
Browse files Browse the repository at this point in the history
…k in the list (#50119)
  • Loading branch information
andrewserong authored Apr 27, 2023
1 parent aa018ec commit 358a423
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ export default function useScrollWhenDragging() {
SCROLL_INACTIVE_DISTANCE_PX,
0
);
const distancePercentage = dragDistance / moveableDistance;
const distancePercentage =
moveableDistance === 0 || dragDistance === 0
? 0
: dragDistance / moveableDistance;
velocityY.current = VELOCITY_MULTIPLIER * distancePercentage;
} else if ( event.clientY < offsetDragStartPosition ) {
// User is dragging upwards.
Expand All @@ -92,7 +95,10 @@ export default function useScrollWhenDragging() {
SCROLL_INACTIVE_DISTANCE_PX,
0
);
const distancePercentage = dragDistance / moveableDistance;
const distancePercentage =
moveableDistance === 0 || dragDistance === 0
? 0
: dragDistance / moveableDistance;
velocityY.current = -VELOCITY_MULTIPLIER * distancePercentage;
} else {
velocityY.current = 0;
Expand Down

1 comment on commit 358a423

@github-actions
Copy link

@github-actions github-actions bot commented on 358a423 Apr 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 358a423.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4825482932
📝 Reported issues:

Please sign in to comment.