<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>267525</bug_id>
          
          <creation_ts>2024-01-15 01:11:20 -0800</creation_ts>
          <short_desc>CSS grid (auto-fit) combined with container-type does not work</short_desc>
          <delta_ts>2025-06-16 00:08:51 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>Safari 17</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          
          <bug_file_loc>https://jsfiddle.net/e6rnamw7/1/</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P3</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Rezi">rezi99</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>karlcow</cc>
    
    <cc>koivisto</cc>
    
    <cc>miriam</cc>
    
    <cc>obrufau</cc>
    
    <cc>rego</cc>
    
    <cc>sgill26</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2005029</commentid>
    <comment_count>0</comment_count>
    <who name="Rezi">rezi99</who>
    <bug_when>2024-01-15 01:11:20 -0800</bug_when>
    <thetext>When element with container query has grid template columns set to auto-fit, the grid is totally ignored and all child elements are stack on top of each other (similar to: width:0; position absolute; top:0; left:0)

replication: https://jsfiddle.net/e6rnamw7/1/

example 

CSS
----------------------------

.wrap{	
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  container-type: inline-size;
}

.item {
  border:1px solid black;
}


HTML
----------------------------

  &lt;div class=&quot;wrap&quot;&gt;
    &lt;div class=&quot;item&quot;&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit. Labore earum, a, maxime, necessitatibus aliquid enim tenetur porro ex delectus odit minima itaque dolores, beatae dolore. Asperiores odit, aspernatur quaerat expedita!&lt;/div&gt;
    &lt;div class=&quot;item&quot;&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit. Labore earum, a, maxime, necessitatibus aliquid enim tenetur porro ex delectus odit minima itaque dolores, beatae dolore. Asperiores odit, aspernatur quaerat expedita!&lt;/div&gt;
    &lt;div class=&quot;item&quot;&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit. Labore earum, a, maxime, necessitatibus aliquid enim tenetur porro ex delectus odit minima itaque dolores, beatae dolore. Asperiores odit, aspernatur quaerat expedita!&lt;/div&gt;
    &lt;div class=&quot;item&quot;&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit. Labore earum, a, maxime, necessitatibus aliquid enim tenetur porro ex delectus odit minima itaque dolores, beatae dolore. Asperiores odit, aspernatur quaerat expedita!&lt;/div&gt;
  &lt;/div&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2005447</commentid>
    <comment_count>1</comment_count>
    <who name="Oriol Brufau">obrufau</who>
    <bug_when>2024-01-16 16:46:57 -0800</bug_when>
    <thetext>https://drafts.csswg.org/css-grid/#valdef-repeat-auto-fit

&gt; The auto-fit keyword behaves the same as auto-fill, except that after grid item placement any empty repeated tracks are collapsed.

It seems that WebKit understands this as having to collapse the tracks when there is size containment.

I don&apos;t recall the details of the interaction of size containment with grid, but I guess the tracks should only collapse during intrinsic sizing, not when laying out for real.

You can see this in Blink, use `display: inline-grid; border: 10px solid magenta` on the grid. The grid is 0px wide when using auto-fit, and 150px wide when using auto-fill. But in both cases the column is 150px wide.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2006495</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-01-22 01:12:14 -0800</bug_when>
    <thetext>&lt;rdar://problem/121359523&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2123895</commentid>
    <comment_count>3</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2025-06-16 00:08:51 -0700</bug_when>
    <thetext>It works fine now on Safari Technology Preview 221.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>