[csswg-drafts] [css-flexbox-1] Intrinsic sizing algorithm seems to produce 0 for many common cases

dholbert has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-flexbox-1] Intrinsic sizing algorithm seems to produce 0 for many common cases ==
I'm reviewing @cbiesinger 's testcase for the (not-implemented-anywhere AFAIK) flexbox intrinsic sizing behavior over in https://github.com/w3c/web-platform-tests/pull/5791 , and I think we might've uncovered some unintended spec behavior with the intrinsic sizing algorithm.  (Though maybe it's intended? Anyway, read on...)

In particular: it seems to me that in many common cases (with empty flex items at least), flex items will contribute 0 to their container's intrinsic size, and the container will be 0-sized as a result.

For example, consider these two cases:
```
  <div style="display:inline-flex;">
    <div style="flex: 1 1 200px"></div>
  </div>

  <div style="display:inline-flex">
    <div style="flex: 1 1 auto; width: 200px"></div>
  </div>
```

Here, you might reasonably expect that each flex item & flex container to be 200px wide. But in both cases, the algorithm ends up sizing the item & container to 0px.  This is because:
 * the items' contributions [depend on their max-content main size](https://drafts.csswg.org/css-flexbox/#intrinsic-item-contributions) which is zero in both cases since they don't have any contents (and an element's min/max-content size isn't influenced by its `flex-basis` or `width`).
 * The spec says the items' `flex-basis` doesn't get to clamp their contributions [because the items are both growable and shrinkable](https://drafts.csswg.org/css-flexbox/#intrinsic-item-contributions)

This behavior (ending up 0-sized) *kind of* makes sense, because the items have no content and no `min-width`/`max-width` properties, which mean's they're "OK" being 0-sized, in a sense -- there's no overflow.  Still: it seems odd for an element with `width:200px` to end up being 0-sized, in a scenario with no constraints.

@tabatkins @fantasai , am I reading the spec correctly here?  And is this zero-sizing the intended spec behavior for cases like this?

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1435 using your GitHub account

Received on Sunday, 21 May 2017 12:56:45 UTC