Open fantasai opened 6 years ago
Fwiw, https://github.com/w3c/csswg-drafts/issues/765 will likely solve the problems with replaced elements in Dave Rupert's post. (Authors will need to use max-width: 100%
to get the right behavior, but this doesn't seem unreasonable.)
Solving scrollable <pre>
/<table>
/whatever inside the grid item is harder, it would require redefining the min-content size of such items; and afaict that would only help in the inline axis.
Discussed this with biesi on Saturday... current idea is to solve this in the inline axis for blocks and in both axes for flex and grid items by assuming a min-content size of zero for overflow
!= visible
.
The Working Group just discussed intrinsic size of 'overflow: auto/scroll' and its impact on auto-sized grid/flex item ancestors
.
To write out the proposal in more detail:
overflow
is non-visible
or oveflow
is scroll | auto
; this is an open issue, since overflow: hidden
is sometimes just used for creating a BFC, at least for blocks.This should address most of the cases where people are confused by the current behavior. Authors who want such box’s min-content size taken into account can use min-width: min-content
which is a relatively straightforward fix for that issue -- the current behavior has effects that cross through descendants which is what's particularly surprising and problematic about it.
The Working Group just discussed Intrinsic sizing and containers for grid/flex sizing
.
Proposal in two parts:
oveflow
!= visible
ignore their content when calculating their min-content contribution (unless opted into that behavior explicitly by setting their width
or min-width
--a specified width (such as width:100px or width:min-content) always takes precedence over one implied by the content when calculating the min-content contribution).
min-width
/min-height
on such boxes, but the min size is just a floor on the min-content size: e.g. if a block has a min-width
of zero (the default) its min-content size is still based on the content. This proposal address the min-content contribution.overflow-inline
!= visible
and overflow-inline
!= hidden
ignore their content when calculating their min-content contribution (〃).
overflow: hidden
because that is frequently used to mean display: flow-root
. (Flex and Grid items don't need this exception because they're flow-roots by default.)The proposal directly address the expectation that authors have that an element with scrollbars is “squishy” because its overflow is already being handled by the choice to scroll. It solves the problem of arbitrary descendants of a grid or flex item unexpectedly expanding its minimum size: this action-at-a-distance is the source of all the confusion and frustration around this issue. (For example, an overflow:visible
flex item, which resolves the default min-width:auto
to its min-content width, can accidentally get super-wide because of a scrollable pre
nested somewhere deep in its descendants, and there's no obvious way to track down that the pre
is the element causing the problem.) In cases where the scrollable box is squished too far, the solution is to add an explicit min-width
or min-height
at the point where there's a problem, which is an understandable and intuitive fix.
Downsides: Potential web-compat where an author set overflow
to a scrollable value expecting that the box would set the size of its container such that this scrollable box has no overflow and doesn't scroll. (Why are you doing this.) Scrollable flex/grid items may shrink down to zero, which isn't very usable, if the author didn't think about handling narrow screens. (E.g. grid-template-columns: auto 1fr
with scrollable grid items; or equivalent layout in Flex.)
The Working Group just discussed [css-sizing][css-grid][css-flexbox] Intrinsic Sizes, Scroll Containers, and Grid/Flex Sizing
.
I'm glad that this issue is getting traction and I'm pretty happy with the direction that it is going in :)
I don't understand what the ramifications of applying this to block as well are. This seems to be a problem that is specific to flexbox and grid.
If this is applied to block, what effects would that have? Or is that what the point of this gathering data phase is for? To figure that part out?
For proposal 1, this is only for row flexboxes, right? (Reasoning being that the min-width: auto behaviour for overflow: non-visible only applies to row flexboxes too)
@cbiesinger It should apply to both. Like Grid, Flexbox is symmetric. You won't notice that if your container is block-level, since blocks always lay out at their max-content size (unless they're fixed-height) but if the item’s flex container is itself embedded in a fixed-height flex/grid container, then the distinction between min/max-content starts to matter.
@fantasai but when calculating the inline-axis min-content contribution of an item in a column flexbox, does it make sense to compute the min-content width of the overflow: auto element to zero?
Just realized I never followed up here; that change was reverted quickly because it broke too much: https://crbug.com/944614 https://crbug.com/941975 https://crbug.com/943496
Retargetting for css-sizing-4: since it looks like we can't change the past, looking into adding a switch (similar concept to box-sizing, except it's a more confusing concept...); see https://github.com/w3c/csswg-drafts/issues/4585
Grid Layout and Flex Layout use automatic minimum sizes (min-content, by default, but depending on the specified
min-width
/min-height
) to prevent grid items and flex items from shrinking too small to be usable. There's an exception to the use of min-content for grid/flex items which have overflow set on them, since authors expect those to shrink below their min-content size. But this exception doesn't follow through to descendants of the grid/flex item, resulting in confusion and frustration for authors. Issue #1777 was filed as a result of such confusion, and Dave Rupert posted http://daverupert.com/2017/09/breaking-the-grid/ discussing the problem.This issue is filed to look into ways to ameliorate the problem: if we can make things Just Work as authors expect, that would be better! Of course Flex and Grid should be affected analogously, thus tagging them both in.