[Scrollable] Fix scrolled to bottom checking for sub-pixel values #3898
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.

WHY are these changes introduced?
Fixes #3607, Fixes #3225
WHAT is this pull request doing?
Certain resolutions, OSes, and browser zoom-level combinations cause
scrollTopto be a sub-pixel value (StackOverflow example), which does not satisfy the strict-equality check on thehasScrolledToBottomcalculation of theScrollablecomponent.In order to catch these cases, and fire the
onScrolledToBottomcallback prop, I've made the strict-equality check a less-than-or-equal to operator.Notes:
Math.ceil(scrollTop)to catch sub-pixel values that are under the threshold, but this introduces another issue whereby scrolling up from the "at bottom" state can cause a re-fire of the callback. In testing, it seems to me thatclientHeightis increased by a pixel at zoom levels wherescrollTopis under the threshold anyway.You can reproduce the original issue on Mac / Chrome by setting your browser zoom level to 67%, 75%, or 125%.
How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
Copy-paste this code in
playground/Playground.tsx:Important — To emulate a breaking resolution, in certain cases you need to set the browser zoom level (e.g. Chrome on Mac) to 67%, 75%, or 125%...
🎩 checklist
Tested on mobileTested for accessibilityUpdated the component'sREADME.mdwith documentation changesTophatted documentation changes in the style guideFor visual design changes, pinged one of @ HYPD, @ mirualves, @ sarahill, or @ ry5n to update the Polaris UI kit