Bug 189324 - [css-position][css-sticky] Negative margin, sibling element flow placement, containing block overflow compatibility between chrome/safari/firefox
Summary: [css-position][css-sticky] Negative margin, sibling element flow placement, c...
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-09-05 16:03 PDT by jonjohnjohnson
Modified: 2021-09-23 08:18 PDT (History)
5 users (show)

See Also:


Attachments
chrome canary (top), safari tech preview (middle), and firefox nightly (bottom) (41.93 KB, image/png)
2018-09-05 16:03 PDT, jonjohnjohnson
no flags Details
chrome canary (top), safari tech preview (middle), and firefox nightly (bottom) (208.41 KB, image/png)
2018-09-05 16:21 PDT, jonjohnjohnson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description jonjohnjohnson 2018-09-05 16:03:22 PDT
Created attachment 348974 [details]
chrome canary (top), safari tech preview (middle), and firefox nightly (bottom)

Steps to reproduce the problem:
1. Open up chrome canary, safari tech preview, and firefox nightly.
2. Go to this test case in each browser -> http://next.plnkr.co/edit/e5bsCLIIF5rtiFOJ?preview
3. Notice how each browser treats negative margins on the green sticky element differently.
4. The case highlights differences in...

- Inaccessible overflow at start edge
- Negative margin on the top edge creating "negative" margin on subsequent sibling element
- Negative margin on the top edge treated differently based upon containing block being the scrolling block with padding or not?

What is the expected behavior?
Uniform position sticky layout between major browsers.

What went wrong?
Major browsers rendering engines behave quite differently when dealing with negative margins on stickily positioned elements.

The attached image shows screenshots of the same test case rendered in chrome canary (top), safari tech preview (middle), and firefox nightly (bottom).

Left side scrolling box has padding, right side scrolling box has a child inside it with equivalent padding values.
Comment 1 jonjohnjohnson 2018-09-05 16:11:34 PDT
In that this is about compatibility and not spec related, here are links to the same issue filed with other browsers.

- https://bugs.chromium.org/p/chromium/issues/detail?id=881102
- https://bugzilla.mozilla.org/show_bug.cgi?id=1488950

Good luck finding agreement.
Comment 2 jonjohnjohnson 2018-09-05 16:21:37 PDT
Created attachment 348977 [details]
chrome canary (top), safari tech preview (middle), and firefox nightly (bottom)

Previous image didn't take into account webkit prefix of sticky property value.
Comment 3 jonjohnjohnson 2018-09-05 16:27:43 PDT
The only major difference between webkit and gecko is at which point the sticky element reaches the opposite edge of its containing block as it scrolls all the way to the end. Safari "grabbing" the sticky element earlier.
Comment 4 Radar WebKit Bug Importer 2018-09-07 14:03:56 PDT
<rdar://problem/44237240>
Comment 5 jonjohnjohnson 2018-11-18 12:08:52 PST
Blink decided to conform to gecko/webkit behavior for negative margin at the sticking scroll edge? So an updated version of the attached screenshot would show consistent behavior.

https://bugs.chromium.org/p/chromium/issues/detail?id=814141#c_ts1524700607

But, Safari STILL has compat issues with how the sticky block is "picked up" (grabbed) when reaching the opposite edge of its containing block. Not sure about Edge, but Safari behaves different than blink/gecko in the test case where a 20 pixels or so before reaching the "scrollend" in the left side scroller, the sticky element begins moving with the flow content.
Comment 6 jonjohnjohnson 2019-01-10 07:58:55 PST
As I spend time thinking about how SCR is created from scroll containers being the offset parent of the sticky element, I think the interop issue shown here is the same as what is reported in https://bugs.webkit.org/show_bug.cgi?id=175029
Comment 7 Martin Robinson 2021-09-23 08:18:04 PDT
Checking against recent versions of WebKit, I think this is behaving the same way in all browsers now. Feel free to leave a comment if this is still an issue and I can reopen this and fix it.