-
Notifications
You must be signed in to change notification settings - Fork 779
Description
Sorry for putting all this in one issue. I'm happy to split things out, but it isn't currently clear to me what's my misunderstanding vs browser bugs vs spec issues. Anyway here goes:
I table-flipped on position-area
I tried using position-area: top on a popover, but it 'didn't work' until I figured out I also needed to set margin: 0. But even with that, the popover was still overflowing the viewport in trivial cases. I felt there was too much magic and restrictions with position-area, so I gave up, and went to the lower level features instead.
I think the margin: 0 issue is tracked here, although it doesn't mention margin specifically. I think the viewport-overflowing issue is down to incorrect implementations.
Should it overflow the viewport by default?
Here's a simple demo, where the popover overflows the viewport in both Chrome and Safari, but the spec says:
If all three tracks are selected, the default alignment in that axis is anchor-center.
And that spec says:
The new anchor-center value makes this case extremely simple: if the positioned box has a default anchor box, then it is centered (insofar as possible) over the default anchor box in the relevant axis.
A note goes on to clarify that it shouldn't overflow the viewport, although I don't see that said in normative text, unless the "insofar as possible" is doing all the heavy lifting?
I'm 90% sure both Chrome and Safari are getting this wrong, but since both are doing the same thing, I wanted to check. Additionally, in a WebKit bug I filed, folks are claiming the overflowing behaviour is 'expected'.
safe and anchor-center
In Chrome:
justify-self: anchor-center- avoids overflowing the viewportjustify-self: safe anchor-center- overflows the viewportjustify-self: unsafe anchor-center- overflows the viewport
In Safari:
justify-self: anchor-center- overflows the viewportjustify-self: safe anchor-center- overflows the viewportjustify-self: unsafe anchor-center- overflows the viewport
Neither of these combinations make sense to me, but I couldn't find anything in the spec to say how these values should interact. It feels like the behaviour should either be:
justify-self: anchor-center- avoids overflowing the viewportjustify-self: safe anchor-center- avoids overflowing the viewportjustify-self: unsafe anchor-center- overflows the viewport
Or:
justify-self: anchor-center- overflows the viewportjustify-self: safe anchor-center- avoids overflowing the viewportjustify-self: unsafe anchor-center- overflows the viewport
…depending on what the default is when safe/unsafe isn't specified. It feels like the second option is more consistent with other uses of justify-self, but I don't have strong feelings.
Implicit anchor elements & pseudo elements
In this demo, I all: unset on the popover, and instead give the popover's ::before and ::after position-area: top and bottom respectively. Chrome & Safari disagree on the position of the popover, and both its pseudo elements.
It seems like, in Chrome, pseudo elements get the implicit anchor element from their parent element. Whereas in Safari, they do not. My gut feeling is that Safari is correct here. Although, it would be nice to have something like position-anchor: inherit-implicit that I could use on inner elements (including pseudos) to pick up the parent implicit anchor element.
I'm not sure what the correct position of the popover should be in this case, other than noting that Chrome & Safari disagree.
I ran into this issue in my 'footnote' popover implementation (click the superscript 8), because I want to all: unset the popover, and instead position an inner element, and an ::after, to independently position the 'bubble' and the arrow. I forgot to set position-anchor on the pseudo, which didn't matter in Chrome, but broke in Safari. But to be clear, I think Safari is right, it's just a compat risk if things appear to 'work' in Chrome due to bugs.
If any of this needs further discussion than just "file a bug with [browser(s)]" or "no you misunderstood", I'll split them off into other issues.