Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts
* @param element - HTMLElement to check scroll state of

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-react-components/Avatar Converged 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Avatar Converged.badgeMask.normal.chromium.png 5 Changed
vr-tests-react-components/Positioning 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Positioning.Positioning end.chromium.png 882 Changed
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 16 Changed
vr-tests-react-components/ProgressBar converged 3 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/ProgressBar converged.Indeterminate + thickness - Dark Mode.default.chromium.png 59 Changed
vr-tests-react-components/ProgressBar converged.Indeterminate + thickness - High Contrast.default.chromium.png 69 Changed
vr-tests-react-components/ProgressBar converged.Indeterminate + thickness.default.chromium.png 27 Changed
vr-tests-react-components/Skeleton converged 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Skeleton converged.Opaque Skeleton with rectangle - Dark Mode.default.chromium.png 9 Changed
vr-tests-react-components/TagPicker 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/TagPicker.disabled - RTL.disabled input hover.chromium.png 635 Changed
vr-tests-react-components/TagPicker.disabled - Dark Mode.disabled input hover.chromium.png 658 Changed

There were 2 duplicate changes discarded. Check the build logs for more information.

*/
const getScrollState = ({ scrollTop, scrollHeight, clientHeight }: HTMLElement): DrawerScrollState => {
const epsilon = 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The change is reasonable, browser layout values can be fractional, so strict equality may fail near the bottom.

Main criticisms:

epsilon = 1 is unexplained and could classify the drawer as bottom while still 1px away. Name it descriptively or document why 1px is acceptable.

The top check remains strict. For consistency, consider scrollTop <= epsilon, especially if fractional or slightly negative values can occur.

Prefer comparing the remaining distance

I'd suggest

const scrollTolerance = 1;

if (scrollHeight <= clientHeight) return 'none';
if (scrollTop <= scrollTolerance) return 'top';
if (scrollHeight - clientHeight - scrollTop <= scrollTolerance) return 'bottom';
return 'middle';

Tests should be added to cover fractional values, exact boundaries, and values within/outside the tolerance.

if (scrollHeight <= clientHeight) {
return 'none';
}
Expand All @@ -31,7 +32,7 @@ const getScrollState = ({ scrollTop, scrollHeight, clientHeight }: HTMLElement):
return 'top';
}

if (scrollTop + clientHeight === scrollHeight) {
if (scrollTop + clientHeight >= scrollHeight - epsilon) {
return 'bottom';
}

Expand Down
Loading