@@ -66,29 +66,29 @@ test('cannot not resize or auto resize column when resizable is not specified',
6666test ( 'should resize column when dragging the handle' , async ( ) => {
6767 const onColumnResize = vi . fn ( ) ;
6868 setup < Row , unknown > ( { columns, rows : [ ] , onColumnResize } ) ;
69- const [ , col2 ] = getHeaderCells ( ) ;
7069 const grid = getGrid ( ) ;
7170 expect ( onColumnResize ) . not . toHaveBeenCalled ( ) ;
7271 await expect . element ( grid ) . toHaveStyle ( { gridTemplateColumns : '100px 200px' } ) ;
72+ const [ , col2 ] = getHeaderCells ( ) ;
7373 await resize ( { column : col2 , resizeBy : - 50 } ) ;
7474 await expect . element ( grid ) . toHaveStyle ( { gridTemplateColumns : '100px 150px' } ) ;
7575 expect ( onColumnResize ) . toHaveBeenCalledExactlyOnceWith ( expect . objectContaining ( columns [ 1 ] ) , 150 ) ;
7676} ) ;
7777
7878test ( 'should use the maxWidth if specified' , async ( ) => {
7979 setup < Row , unknown > ( { columns, rows : [ ] } ) ;
80- const [ , col2 ] = getHeaderCells ( ) ;
8180 const grid = getGrid ( ) ;
8281 await expect . element ( grid ) . toHaveStyle ( { gridTemplateColumns : '100px 200px ' } ) ;
82+ const [ , col2 ] = getHeaderCells ( ) ;
8383 await resize ( { column : col2 , resizeBy : 1000 } ) ;
8484 await expect . element ( grid ) . toHaveStyle ( { gridTemplateColumns : '100px 400px' } ) ;
8585} ) ;
8686
8787test ( 'should use the minWidth if specified' , async ( ) => {
8888 setup < Row , unknown > ( { columns, rows : [ ] } ) ;
89- const [ , col2 ] = getHeaderCells ( ) ;
9089 const grid = getGrid ( ) ;
9190 await expect . element ( grid ) . toHaveStyle ( { gridTemplateColumns : '100px 200px' } ) ;
91+ const [ , col2 ] = getHeaderCells ( ) ;
9292 await resize ( { column : col2 , resizeBy : - 150 } ) ;
9393 await expect . element ( grid ) . toHaveStyle ( { gridTemplateColumns : '100px 100px' } ) ;
9494} ) ;
@@ -105,9 +105,9 @@ test('should auto resize column when resize handle is double clicked', async ()
105105 ] ,
106106 onColumnResize
107107 } ) ;
108- const [ , col2 ] = getHeaderCells ( ) ;
109108 const grid = getGrid ( ) ;
110109 await expect . element ( grid ) . toHaveStyle ( { gridTemplateColumns : '100px 200px' } ) ;
110+ const [ , col2 ] = getHeaderCells ( ) ;
111111 await autoResize ( col2 ) ;
112112 await expect . element ( grid ) . toHaveStyle ( { gridTemplateColumns : '100px 327.703px' } ) ;
113113 // This is called twice in strict mode
@@ -124,9 +124,9 @@ test('should use the maxWidth if specified on auto resize', async () => {
124124 }
125125 ]
126126 } ) ;
127- const [ , col2 ] = getHeaderCells ( ) ;
128127 const grid = getGrid ( ) ;
129128 await expect . element ( grid ) . toHaveStyle ( { gridTemplateColumns : '100px 200px' } ) ;
129+ const [ , col2 ] = getHeaderCells ( ) ;
130130 await autoResize ( col2 ) ;
131131 await expect . element ( grid ) . toHaveStyle ( { gridTemplateColumns : '100px 400px' } ) ;
132132} ) ;
@@ -141,9 +141,50 @@ test('should use the minWidth if specified on auto resize', async () => {
141141 }
142142 ]
143143 } ) ;
144- const [ , col2 ] = getHeaderCells ( ) ;
145144 const grid = getGrid ( ) ;
146145 await expect . element ( grid ) . toHaveStyle ( { gridTemplateColumns : '100px 200px' } ) ;
146+ const [ , col2 ] = getHeaderCells ( ) ;
147147 await autoResize ( col2 ) ;
148148 await expect . element ( grid ) . toHaveStyle ( { gridTemplateColumns : '100px 100px' } ) ;
149149} ) ;
150+
151+ test ( 'should remeasure flex columns when resizing a column' , async ( ) => {
152+ setup <
153+ {
154+ readonly col1 : string ;
155+ readonly col2 : string ;
156+ readonly col3 : string ;
157+ } ,
158+ unknown
159+ > ( {
160+ columns : [
161+ {
162+ key : 'col1' ,
163+ name : 'col1' ,
164+ resizable : true
165+ } ,
166+ {
167+ key : 'col2' ,
168+ name : 'col2' ,
169+ resizable : true
170+ } ,
171+ {
172+ key : 'col3' ,
173+ name : 'col3' ,
174+ resizable : true
175+ }
176+ ] ,
177+ rows : [
178+ {
179+ col1 : 'a' . repeat ( 10 ) ,
180+ col2 : 'a' . repeat ( 10 ) ,
181+ col3 : 'a' . repeat ( 10 )
182+ }
183+ ]
184+ } ) ;
185+ const grid = getGrid ( ) ;
186+ await expect . element ( grid ) . toHaveStyle ( { gridTemplateColumns : '639.328px 639.328px 639.344px' } ) ;
187+ const [ col1 ] = getHeaderCells ( ) ;
188+ await autoResize ( col1 ) ;
189+ await expect . element ( grid ) . toHaveStyle ( { gridTemplateColumns : '79.1406px 919.422px 919.438px' } ) ;
190+ } ) ;
0 commit comments