You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR fixes floating-point rounding issues in scroll edge detection by introducing a 1px tolerance when determining if the viewport is scrolled to an edge. The change prevents scenarios where scroll positions like maxScroll - 0.5px incorrectly show as not fully scrolled.
Created normalizeScrollOffset utility that snaps scroll values within 1px of edges to the actual edge value
Applied normalization to both horizontal and vertical scroll calculations in ScrollAreaViewport
Removed redundant clamping operations that were duplicating the work done by normalizeScrollOffset
Added comprehensive test coverage for the edge-rounding behavior
Confidence Score: 5/5
This PR is safe to merge with no identified issues
The implementation is clean, well-tested, and addresses a specific floating-point precision bug. The 1px tolerance is reasonable for browser rendering, the logic is straightforward, and the change is properly covered by new tests
Normalize end offsets for tiny scroll ranges — packages/react/src/scroll-area/utils/scrollEdges.ts:12-17 When the scroll range is ≤ 1px (e.g., content is only 1px larger than the viewport), normalizeScrollOffset always returns 0 because the start-edge check runs before the end-edge check. That means even at scrollLeft === max, the normalized value stays 0 and scrollLeftFromEnd stays max, so data-overflow-*-end never clears. This shows up whenever the scrollable range is 1px or less. Consider handling overlapping tolerances (e.g., compare distance to each edge or special-case max <= tolerance) so the end state can be reached.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Fixes #3795 (comment)