-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(drawer): tolerate fractional scroll metrics #36520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts | |
| * @param element - HTMLElement to check scroll state of | ||
| */ | ||
| const getScrollState = ({ scrollTop, scrollHeight, clientHeight }: HTMLElement): DrawerScrollState => { | ||
| const epsilon = 1; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
The top check remains strict. For consistency, consider Prefer comparing the remaining distance I'd suggest Tests should be added to cover fractional values, exact boundaries, and values within/outside the tolerance. |
||
| if (scrollHeight <= clientHeight) { | ||
| return 'none'; | ||
| } | ||
|
|
@@ -31,7 +32,7 @@ const getScrollState = ({ scrollTop, scrollHeight, clientHeight }: HTMLElement): | |
| return 'top'; | ||
| } | ||
|
|
||
| if (scrollTop + clientHeight === scrollHeight) { | ||
| if (scrollTop + clientHeight >= scrollHeight - epsilon) { | ||
| return 'bottom'; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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
vr-tests-react-components/Positioning 2 screenshots
vr-tests-react-components/ProgressBar converged 3 screenshots
vr-tests-react-components/Skeleton converged 1 screenshots
vr-tests-react-components/TagPicker 2 screenshots
There were 2 duplicate changes discarded. Check the build logs for more information.