Skip to content
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

fix (react-dialog): Use consistent rounding for clientHeight and innerHeight #32480

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
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
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: Adjust window height comparison in fractional cases.",
"packageName": "@fluentui/react-dialog",
"email": "owcampbe@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export function useDisableBodyScroll(): {
return;
}
const isHorizontalScrollbarVisible =
targetDocument.body.clientHeight > (targetDocument.defaultView?.innerHeight ?? 0);
// When the window is a fractional height, `innerHeight` always rounds down but `clientHeight` rounds either up or down depending on the value.
// To properly compare the body clientHeight to the window innerHeight, manually round down the fractional value to match innerHeight's calculation.
Math.floor(targetDocument.body.getBoundingClientRect().height) > (targetDocument.defaultView?.innerHeight ?? 0);
micahgodbolt marked this conversation as resolved.
Show resolved Hide resolved
if (!isHorizontalScrollbarVisible) {
return;
}
Expand Down
Loading