Re: [csswg-drafts] [css-anchor-position] Better handling of scroll position for fixpos elements on first layout (#10999)

Screenshots to illustrate the problem, based on the example in my previous comment.

The popup is using `position-area: bottom span-right;` to position itself below the button that invokes it. It's a fixpos element, so it uses the viewport as its containing block; thus, the position area it selects should stretch from the bottom of the button to the bottom of the screen, and from the left edge of the button to the right edge of the screen.

----------------

First, this screenshot shows what happens if the popup is opened when the scroller is at its initial scroll position. This is *expected* behavior, it's doing exactly what the author likely intends, based on the above description of its styling.

![Screenshot from 2024-10-15 15-13-15](https://github.com/user-attachments/assets/30d897e5-1f5a-40aa-a97e-22edce6bb530)

---------------

Now, scroll that scroller a bit down and to the right, so the button is higher and lefter in the scrollport, *then* click it to open the popup. What the author almost certainly *expects* to see is:

![Screenshot from 2024-10-15 15-26-34](https://github.com/user-attachments/assets/a4edee93-6c04-43ff-9be6-002ef013d0fd)

That is, it still stretches between the anchor and the viewport edge, exactly as it did in the first case, just with more space to work with since the anchor has been scrolled away from those edges a bit.

-------------

But that's not what happens! Instead, they get this:

![Screenshot from 2024-10-15 15-18-25](https://github.com/user-attachments/assets/797ca959-73ba-4a92-a54f-89bafaf51437)

This almost certainly isn't expected! The popup's position-area doesn't look correct; it no longer stretches to the bottom or the right of the screen! This is because, per spec, we calculate this position-area based on the *initial scroll position*. That means it's actually the exact size it was in the first example, but that size no longer corresponds to the desired position-area edges.

--------------

Arguably the author might expect it to *stay* sized exactly to those two edges as it scrolls, but as explained in the previous comment, that's intentionally not possible. But it's absolutely possible to trigger this expected sizing *once*, as the popup starts displaying, and also when we swap the position-try-fallback (since the fallback calculation *does* correctly take scrolling into account).

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10999#issuecomment-2415284548 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 15 October 2024 22:33:15 UTC