@@ -137,6 +137,36 @@ test('should use the fallback value for columns without explicit width', () => {
137137 ] ) ;
138138} ) ;
139139
140+ test ( 'should respect minWidth when dynamically adding columns via visibleColumns' , ( ) => {
141+ const columns : TableProps . ColumnDefinition < Item > [ ] = [
142+ { id : 'id' , header : '' , cell : item => item . id , width : 100 } ,
143+ { id : 'small-width' , header : '' , cell : ( ) => '-' , width : 80 , minWidth : 150 } ,
144+ { id : 'width-only' , header : '' , cell : ( ) => '-' , width : 180 } ,
145+ { id : 'minWidth-larger' , header : '' , cell : ( ) => '-' , width : 180 , minWidth : 200 } ,
146+ ] ;
147+ const { wrapper, rerender } = renderTable (
148+ < Table columnDefinitions = { columns } visibleColumns = { [ 'id' ] } items = { defaultItems } resizableColumns = { true } />
149+ ) ;
150+ expect ( wrapper . findColumnHeaders ( ) . map ( column => column . getElement ( ) . style . width ) ) . toEqual ( [ '100px' ] ) ;
151+
152+ // Dynamically add columns with various width/minWidth configurations
153+ rerender (
154+ < Table
155+ columnDefinitions = { columns }
156+ visibleColumns = { [ 'id' , 'small-width' , 'width-only' , 'minWidth-larger' ] }
157+ items = { defaultItems }
158+ resizableColumns = { true }
159+ />
160+ ) ;
161+
162+ expect ( wrapper . findColumnHeaders ( ) . map ( column => column . getElement ( ) . style . width ) ) . toEqual ( [
163+ '100px' , // original column unchanged
164+ '150px' , // use minWidth because 150 > 80
165+ '180px' , // sue width (minWidth defaults to width)
166+ '200px' , // use minWidth because 200 > 180
167+ ] ) ;
168+ } ) ;
169+
140170describe ( 'reading widths from the DOM' , ( ) => {
141171 const originalBoundingClientRect = HTMLElement . prototype . getBoundingClientRect ;
142172 beforeEach ( ( ) => {
0 commit comments