Skip to content

Commit

Permalink
fix: Use correct window to get the devicePixelRatio
Browse files Browse the repository at this point in the history
The `roundOffsetsByDPR` utility was using the global window keyword
instead of the `getWindow` utility. This meant that applications that
render to childe windows would have blurry poppers sincee the device pixel
ratio being used wouldn't be correct.Two cases where that could
happen:

* Parent window in another monitor
* Parent window has a different zoom than the child window
  • Loading branch information
ling1726 committed Mar 14, 2023
1 parent 2893e9a commit ff3ed73
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/modifiers/computeStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ const unsetSides = {
// Round the offsets to the nearest suitable subpixel based on the DPR.
// Zooming can change the DPR, but it seems to report a value that will
// cleanly divide the values into the appropriate subpixels.
function roundOffsetsByDPR({ x, y }): Offsets {
const win: Window = window;
function roundOffsetsByDPR({ x, y }, win: Window): Offsets {
const dpr = win.devicePixelRatio || 1;

return {
Expand Down Expand Up @@ -150,7 +149,7 @@ export function mapToStyles({

({ x, y } =
roundOffsets === true
? roundOffsetsByDPR({ x, y })
? roundOffsetsByDPR({ x, y }, getWindow(popper))
: { x, y });

if (gpuAcceleration) {
Expand Down

0 comments on commit ff3ed73

Please sign in to comment.