@@ -44,6 +44,18 @@ describe('column auto-width', () => {
4444 } ) ;
4545 }
4646
47+ class TestContainer extends HTMLElement {
48+ constructor ( ) {
49+ super ( ) ;
50+ this . attachShadow ( { mode : 'open' } ) ;
51+ this . shadowRoot . innerHTML = `
52+ <slot name="custom-slot"></slot>
53+ ` ;
54+ }
55+ }
56+
57+ customElements . define ( 'test-container' , TestContainer ) ;
58+
4759 beforeEach ( async ( ) => {
4860 grid = fixtureSync ( `
4961 <vaadin-grid style="width: 600px; height: 200px;" hidden>
@@ -160,6 +172,31 @@ describe('column auto-width', () => {
160172 grid . recalculateColumnWidths ( ) ;
161173 expectColumnWidthsToBeOk ( columns , [ 114 ] ) ;
162174 } ) ;
175+
176+ it ( 'should defer calculating column widths when the grid is not visible' , async ( ) => {
177+ grid . items = testItems ;
178+ await recalculateWidths ( ) ;
179+ expectColumnWidthsToBeOk ( columns , [ 74 ] ) ;
180+
181+ // Move grid to a custom element without setting proper slot name beforehand
182+ // This reproduces a case in split-layout, which automatically applies slot
183+ // names to children, but only after they have been connected. In this case
184+ // columns should not resize while the grid is invisible, because their size
185+ // would collapse to zero.
186+ const container = fixtureSync ( '<test-container></test-container>' ) ;
187+ container . appendChild ( grid ) ;
188+
189+ // Column widths should not have recalculated
190+ await nextFrame ( ) ;
191+ expectColumnWidthsToBeOk ( columns , [ 74 ] ) ;
192+
193+ // Apply correct slot name
194+ grid . slot = 'custom-slot' ;
195+
196+ // Column widths should recalculate, keeping the same width
197+ await recalculateWidths ( ) ;
198+ expectColumnWidthsToBeOk ( columns , [ 74 ] ) ;
199+ } ) ;
163200} ) ;
164201
165202describe ( 'tree column' , ( ) => {
0 commit comments