Negative margin causes sticky positioned elements to render at incorrect position on screen
Reported by
wb...@box.com,
Jun 26 2018
|
||||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36 Steps to reproduce the problem: http://next.plnkr.co/edit/7eXQu5s2pQEjaa4b (same as the attached file) If the top value is consistent with the negative margin then the rendered position is reconciled with the clickable region, but it incorrectly scrolls beyond the expected region, which is inconsistent with observed behavior on Firefox. What is the expected behavior? The clickable region should never deviate from the rendered element What went wrong? The element is drawn offset from where it actually exists on the page. This inconsistency can be viewed via the Element's tab in the Developer Tools pane. This behavior appears correct in Firefox, although the interaction between top, a negative top-margin, and position sticky is still strange. Did this work before? N/A Does this work in other browsers? Yes Chrome version: 67.0.3396.99 Channel: stable OS Version: OS X 10.11.6 Flash Version: How position sticky interacts with negative margins is not well documented.
,
Jun 26 2018
Able to reproduce the issue on Mac 10.13.3 using chrome reported version #67.0.3396.99 and latest canary #69.0.3472.3. Issue is specific to OS-mac. This is a non-regression issue as it is observed from M60 old builds. Hence, marking it as untriaged to get more inputs from dev team. Thanks...!!
,
Jun 28 2018
Over to flackr for position sticky triage.
,
Jul 19
Actually their is still compat issues with firefox and negative top margin... I added to the original testcase a wee bit to see how all 3 browsers behave differently. Primarily by making the header not fully opaque, so you can see how the content alongside the sticky header behaves. http://next.plnkr.co/edit/QkTDlr9FRKxijejC I also added a second scroller that has the padding not on the scrolling element, but on a wrapper element inside the scroller. Notice how this padding changes effect firefox compared the chrome/safari. This may be due to the age old https://github.com/w3c/csswg-drafts/issues/129.
,
Jul 19
To be clear the compat issue is not my primary concern. Yes, there are subtle differences between how the sticky positioned elements are rendered/scrolled in relation to padding/margin. I'd prefer to avoid pinning this ticket to that problem. My primary concern is that the elements interactable/clickable region becomes inconsistent with where it is actually rendered on screen in Blink. If you view your plunkr in Firefox both the left and right submit buttons' interact regions match their rendered element. n Chrome the left submit button becomes inconsistent while the right button remains consistent.
,
Aug 2
I can see the issue as well. CC'ing more folks who are more expert in this area for triaging.
,
Aug 2
The Chrome issue seems to be related in a difference of behavior in out main thread and compositor thread position sticky path. On my linux box, I can repro the issue if I force the <div class='main'> to be composited [1]. Doing so, puts the sticky element at a different position. Our main thread implementation behavior matches the Firefox. See attached screenshots. More importantly the fact that compositor calculated position is different from main thread, results in incorrect hit-testing as pointed out by the original report. I am not going to guess wether main offset calculation is correct or not but regardless we need to ensure out compositor code path computes the same offset as main. [1] e.g. by adding 'backface-visibility: hidden;'
,
Aug 2
/cc yigu@ and smcgruer@ who have worked on stick code most recently. BTW, if you want to see something **fun** use larger negative margins when container is composited.
,
Aug 2
,
Dec 10
Seems like this could have been inadvertently *fixed, as the broken behavior I used to see in the test case is now gone.
,
Dec 10
|
||||||
►
Sign in to add a comment |
||||||
Comment 1 by gov...@chromium.org
, Jun 26 2018Labels: Needs-Triage-M67