Popper-core: Strategy "fixed" generates incorrect popper position in Safari

Created on 4 Jun 2020  路  11Comments  路  Source: popperjs/popper-core

CodeSandbox demo

https://codesandbox.io/s/strange-hooks-nukkq?file=/src/index.js

Steps to reproduce the problem

  1. Open the demo in Safari (iOS or desktop)
  2. Open the sandbox embedded browser in a new window
  3. Zoom-in browser window using the pinch-to-zoom gesture
  4. Scroll the page

What is the expected behavior?

Popper should stay on the bottom side of the reference element when scrolling.

What went wrong?

Popper goes up as far as the scroll position changes.

Any other comments?

# BUG 馃悶 medium browser compat

Most helpful comment

Oh right I made that bug report 馃

All 11 comments

What version of Safari are you on? With 13.1 everything looks good to me.

The version is 13.1.1. It's important to use the pinch-to-zoom gesture on the trackpad, not command+plus. Or use a mobile browser.

IMG-9008

Oh ok thanks, I missed that step, yes I can reproduce it.

Hey, we're running into this issue too!

Looking at the example, it seems like some logic kicks-in whenever it's pinch zoomed. The logic will manually reposition popper (see attached) on scroll thereafter.

I'm completely new to this project so sorry if I'm stating the obvious here but i hope it helps anyway - ha 馃槣 I'll have poke around today and see if i can find anything else.

Kapture 2020-06-15 at 13 38 35

After some more digging i've found that the issue is related to this line:

https://github.com/popperjs/popper-core/blob/38914aae7a2e91715c6eb2b563517082a40cfa64/src/modifiers/computeStyles.js#L87

The result of this calculation x -= offsetParent.clientWidth - popperRect.width; changes when we use cmd + and cmd - but if you use pinch to zoom, the calculation remains the same, as if there was no zoom at all.

For example:

  • No zoom: x -= offsetParent.clientWidth - popperRect.width; = 366
  • Zoom: x -= offsetParent.clientWidth - popperRect.width; = 313
  • Pinch zoom: x -= offsetParent.clientWidth - popperRect.width; = 366

Right now i'm thinking that the offsetParent.clientWidth isn't being updated in Safari like we would otherwise expect.

hmmm. appears that this is the culprit: https://stackoverflow.com/questions/6163174/detect-page-zoom-change-with-jquery-in-safari

Safari wont include the zoom in clientWidth & clientHeight but it will update the window.innerWidth / Height...

Hi all, looks like this issue is already fixed in v2.4.1

See this PR

@atomiks we can probably close this issue for now, thanks 馃槃

@danieldelcore I can still reproduce it updating to 2.4.1 & 2.4.2 in the CodeSandbox

Sorry about that, yea can still confirm that this is an issue

I took some time to investigate this issue today, and it looks like like the issue is caused at least in part by a Webkit bug with calculating getBoundingClientRect() when using pinch-to-zoom. Popper.js wraps this function and uses it in a bunch of places to calculate positioning. I assume the same bug causes the inconsistencies with offsetParent that Dan mentioned above.

The bug is tracked in the Webkit issue tracker here, including a simpler popper example as a demonstration: https://bugs.webkit.org/show_bug.cgi?id=207089

I'll look into whether there's an alternate way we can calculate the reference's bounding box and position, and will update in a few hours

Oh right I made that bug report 馃

Was this page helpful?
4 / 5 - 1 ratings

Related issues

skitterm picture skitterm  路  5Comments

memboc picture memboc  路  3Comments

NilsEnevoldsen picture NilsEnevoldsen  路  5Comments

QJan84 picture QJan84  路  4Comments

FezVrasta picture FezVrasta  路  3Comments