@@ -1563,6 +1563,54 @@ describe('IgxGrid - Column properties #grid', () => {
15631563 expect ( grid . columns . find ( x => x . field === 'Fax' ) . width ) . toBe ( '130px' ) ;
15641564 } ) ) ;
15651565
1566+ it ( 'should rebuild horizontal size cache for auto-sized columns when scrolled into view.' , ( fakeAsync ( ( ) => {
1567+ const fix = TestBed . createComponent ( ResizableColumnsComponent ) ;
1568+ const cols = [ ] ;
1569+ const data = [ ] ;
1570+ for ( let j = 0 ; j < 20 ; j ++ ) {
1571+ cols . push ( {
1572+ field : ( j + 1 ) . toString ( ) ,
1573+ width : 'auto'
1574+ } ) ;
1575+ }
1576+ const obj = { } ;
1577+ for ( let j = 0 ; j < cols . length ; j ++ ) {
1578+ const col = cols [ j ] . field ;
1579+ obj [ col ] = j ;
1580+ }
1581+
1582+ for ( let i = 0 ; i < 100 ; i ++ ) {
1583+ const newObj = Object . create ( obj ) ;
1584+ newObj [ 'ID' ] = i ;
1585+ data . push ( newObj ) ;
1586+ }
1587+ fix . componentInstance . columns = cols ;
1588+ fix . componentInstance . data = data ;
1589+ fix . detectChanges ( ) ;
1590+ tick ( 100 ) ;
1591+ fix . detectChanges ( ) ;
1592+ const grid = fix . componentInstance . instance ;
1593+ let state = grid . headerContainer . state ;
1594+ let visibleColumnSizes = ( grid . headerContainer as any ) . individualSizeCache . slice ( state . startIndex , state . startIndex + state . chunkSize ) ;
1595+ const expectedAutoSize = 68 ;
1596+ for ( const val of visibleColumnSizes ) {
1597+ expect ( val ) . toBe ( expectedAutoSize ) ;
1598+ }
1599+
1600+ const horizontalScroller = grid . headerContainer . getScroll ( ) ;
1601+ horizontalScroller . scrollLeft = horizontalScroller . scrollWidth ;
1602+ horizontalScroller . dispatchEvent ( new Event ( 'scroll' ) ) ;
1603+ tick ( 100 ) ;
1604+ fix . detectChanges ( ) ;
1605+
1606+ state = grid . headerContainer . state ;
1607+ expect ( state . startIndex ) . not . toBe ( 0 ) ;
1608+ visibleColumnSizes = ( grid . headerContainer as any ) . individualSizeCache . slice ( state . startIndex , state . startIndex + state . chunkSize ) ;
1609+ for ( const val of visibleColumnSizes ) {
1610+ expect ( val ) . toBe ( expectedAutoSize ) ;
1611+ }
1612+ } ) ) ) ;
1613+
15661614 it ( 'should auto-size correctly when cell has custom template' , fakeAsync ( ( ) => {
15671615 const fix = TestBed . createComponent ( ResizableColumnsComponent ) ;
15681616 const grid = fix . componentInstance . instance ;
0 commit comments