@@ -44,6 +44,18 @@ describe('column auto-width', () => {
44
44
} ) ;
45
45
}
46
46
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
+
47
59
beforeEach ( async ( ) => {
48
60
grid = fixtureSync ( `
49
61
<vaadin-grid style="width: 600px; height: 200px;" hidden>
@@ -160,6 +172,31 @@ describe('column auto-width', () => {
160
172
grid . recalculateColumnWidths ( ) ;
161
173
expectColumnWidthsToBeOk ( columns , [ 114 ] ) ;
162
174
} ) ;
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
+ } ) ;
163
200
} ) ;
164
201
165
202
describe ( 'tree column' , ( ) => {
0 commit comments