Skip to content

[css-anchor-position] Clarification: effect of position-try-fallbacks and position-try-order when the positioned box does not overflow #13268

@jfkthame

Description

@jfkthame

The spec for position-try-fallbacks says that this property provides

alternate positioning styles to try when the absolutely positioned box overflows its inset-modified containing block

(my emphasis) which implies that if the positioned box does not overflow its IMCB, the fallbacks listed will not be used.

The position-try-order property extends this feature by providing control over the order in which the fallbacks are tried (other than simply "as listed").

I note that the position options list that position-try-order potentially re-sorts includes the positioned box's original "base" position as well as the fallback positions from the try-fallbacks list. However, if the positioned box did not overflow its IMCB, there is no reason to (construct or) use this position options list at all, because the basic condition for using position-try-fallbacks ("when the absolutely positioned box overflows...") is not met.

I'm bringing this up because while this is my understanding of the properties described in the spec, it does not match the behavior I currently see in Chrome. The testcase at https://codepen.io/jfkthame/pen/raLaBbx has an anchored element that fits comfortably (without overflow) in its IMCB at position-area: top left. The checkbox allows additional properties position-try-fallbacks and position-try-order to be applied to it (and changes the color to red). By my reading of the spec, this should not cause the anchored element to move, because it didn't overflow and therefore position-try-fallbacks is not relevant. But in Chrome, the flip-block flip-inline fallback gets used, and the element jumps to the bottom right area. It looks like Chrome is using the sorted position options list even though no fallback was required.

Is this the expected result? It doesn't seem to me that it follows from the property descriptions in the spec. But there's a WPT reftest whose reference currently assumes the Chrome behavior.

I'd argue that the Chrome behavior is a bug (or misunderstanding of the spec), and the position-try-order-logical test is bogus, but I'd like to know whether the WG agrees, or if my interpretation is at fault here.

@fantasai I notice that Safari does not share Chrome's (questionable) behavior on this example; does this mean your understanding here matches mine?

(Also tagging @emilio to add anything I've forgotten.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions