Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-flexbox] Resolving flex item ‘auto’ preferred size for max-content contribution #6455

Closed
andyjakubowski opened this issue Jul 15, 2021 · 2 comments
Labels
Closed Accepted as Obvious Bugfix Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-flexbox-1 Current Work Tested Memory aid - issue has WPT tests

Comments

@andyjakubowski
Copy link

andyjakubowski commented Jul 15, 2021

I’m trying to figure out how to resolve an auto preferred size of a flex item to calculate its max-content contribution as part of calculating the max-content intrinsic main size of a flex container.

§ 9.9.3. Flex Intrinsic Size Contributions specifies the following (emphasis mine):

The main-size max-content contribution of a flex item is the larger of its outer max-content size and outer preferred size (its width/height as appropriate) clamped by its flex base size as a maximum (if it is not growable) and/or as a minimum (if it is not shrinkable), and then further clamped by its min/max main size.

My flex item has width: auto. CSS-SIZING-3 defers to the relevant layout module to calculate this. But the main size of a flex item is determined via flex-basis and the Flexbox layout algorithm. So if flex-basis is anything else than auto (in which case it does look at width or height as appropriate), width or height seems to be effectively ignored.

How should I resolve a preferred size (width or height) of auto for a flex item? Should I follow the same steps as the steps for determining the flex base size outlined in § 9.2.3.E Determine the flex base size and hypothetical main size of each item? Where we ultimately look at the max-content size of an item if flex-basis: auto and width: auto (or height: auto)?

@tabatkins tabatkins added the css-flexbox-1 Current Work label Jul 16, 2021
@tabatkins
Copy link
Member

Oh jeez, looking at the blame for that section, that text was touched in 1992cf3. It's clear that we meant to have the "if it's not auto" rider on both contribution calculations, but for some reason accidentally omitted it from the max-content one.

It was present in both in the changelog's quote of the changed text! We just messed up in the actual spec text! Silly of us.

Anyway, thanks for spotting this and bringing it up. It should be clear now that, like for min-content contribution, you'd ignore the specified width in this case and just use the outer max-content size.

@fantasai fantasai added Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. and removed Commenter Response Pending labels Aug 12, 2021
@fantasai
Copy link
Collaborator

Testcase added: web-platform-tests/wpt#30569

@fantasai fantasai added the Tested Memory aid - issue has WPT tests label Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed Accepted as Obvious Bugfix Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-flexbox-1 Current Work Tested Memory aid - issue has WPT tests
Projects
None yet
Development

No branches or pull requests

3 participants