Skip to content

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

Closed

Description

@andyjakubowski

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)?

Activity

  1. tabatkins commented on Aug 10, 2021

    @tabatkins
    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.

  2. fantasai commented on Sep 16, 2021

    @fantasai
    Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closed Accepted as Obvious BugfixFixed an obvious error with the obvious solution.Commenter SatisfiedCommenter has indicated satisfaction with the resolution / edits.TestedMemory aid - issue has WPT testscss-flexbox-1Current Work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions