[data grid] fix renderContext
calculation with scroll bounce / over-scroll
#16297
+47
−32
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 an age old bug that has made the Datagrid look really broken on iOS devices.
Turns out there's a faulty logic that prevents renderContext from being recalculated when overscrolling – it skips calculating a new render context if the scroller is out of bounds, which results in blank rows intermittently. Fixed it by clamping within the known scroll area instead to avoid any unnecessary recalculations when bouncing, while still updating the render context when needed.
Steps to reproduce:
It's very annoying, since there's no directional scroll locks, so natural motion can easily trigger even the tiniest of overscrolls and this bug looks like this (no rows displayed while actively scrolling):
https://github.com/user-attachments/assets/d431e8f3-60c0-4914-b098-ed901195e38c
I also added in a small performance optimisation to reduce the number of calls to
scrollTop/scrollLeft
properties (centralised totriggerUpdateRenderContext
), which can cause re-measurements when called in different times (depends on browser implementation).Related issue #14930 (was never solved)