Skip to content

Commit

Permalink
fix (react-dialog): Use consistent rounding for clientHeight and inne…
Browse files Browse the repository at this point in the history
…rHeight (#32480)
  • Loading branch information
CampbellOwen authored Sep 10, 2024
1 parent e98c6f0 commit 01cacb0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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);
if (!isHorizontalScrollbarVisible) {
return;
}
Expand Down

0 comments on commit 01cacb0

Please sign in to comment.