@@ -25,7 +25,7 @@ import { ISortingExpression, SortingDirection } from '../../data-operations/sort
2525import { GRID_SCROLL_CLASS } from '../../test-utils/grid-functions.spec' ;
2626import { AsyncPipe , NgFor , NgIf } from '@angular/common' ;
2727import { IgxPaginatorComponent , IgxPaginatorContentDirective } from '../../paginator/paginator.component' ;
28- import { IGridRowEventArgs , IgxGridFooterComponent , IgxGridRow , IgxGroupByRow , IgxSummaryRow } from '../public_api' ;
28+ import { IGridRowEventArgs , IgxColumnGroupComponent , IgxGridFooterComponent , IgxGridRow , IgxGroupByRow , IgxSummaryRow } from '../public_api' ;
2929import { getComponentSize } from '../../core/utils' ;
3030import { setElementSize } from '../../test-utils/helper-utils.spec' ;
3131
@@ -1900,6 +1900,20 @@ describe('IgxGrid Component Tests #grid', () => {
19001900
19011901 expect ( calcWidth ) . not . toBe ( 80 ) ;
19021902 } ) ;
1903+
1904+ it ( 'should correctly autosize column headers inside column groups.' , async ( ) => {
1905+ const fix = TestBed . createComponent ( IgxGridColumnHeaderInGroupAutoSizeComponent ) ;
1906+ const grid = fix . componentInstance . grid ;
1907+ grid . data = [ { field1 : "Test" } ] ;
1908+
1909+ //waiting for reqeustAnimationFrame to finish
1910+ fix . detectChanges ( ) ;
1911+ await wait ( 17 ) ;
1912+ fix . detectChanges ( ) ;
1913+
1914+ const calcWidth = parseInt ( grid . getColumnByName ( "field1" ) . calcWidth ) ;
1915+ expect ( calcWidth ) . toBe ( 126 ) ;
1916+ } ) ;
19031917 } ) ;
19041918
19051919 describe ( 'IgxGrid - API methods' , ( ) => {
@@ -2994,6 +3008,36 @@ export class IgxGridColumnHeaderAutoSizeComponent {
29943008
29953009}
29963010
3011+ @Component ( {
3012+ template : `
3013+ <igx-grid #grid>
3014+ <igx-column-group>
3015+ <igx-column
3016+ field="field1"
3017+ header="Field 1 Header"
3018+ width="auto"
3019+ ></igx-column>
3020+ <igx-column
3021+ field="field2"
3022+ header="Field 2 Header"
3023+ width="auto"
3024+ ></igx-column>
3025+ <igx-column
3026+ field="field3"
3027+ header="Field 3 Header"
3028+ width="auto"
3029+ ></igx-column>
3030+ </igx-column-group>
3031+ </igx-grid>` ,
3032+ standalone : true ,
3033+ imports : [ IgxGridComponent , IgxColumnComponent , IgxColumnGroupComponent ]
3034+
3035+ } )
3036+ export class IgxGridColumnHeaderInGroupAutoSizeComponent {
3037+ @ViewChild ( 'grid' , { read : IgxGridComponent , static : true } )
3038+ public grid : IgxGridComponent ;
3039+ }
3040+
29973041@Component ( {
29983042 template : `<igx-grid #grid [data]="data" [width]="'500px'" (columnInit)="initColumns($event)">
29993043 <igx-column *ngFor="let col of columns" [field]="col.key" [header]="col.key" [dataType]="col.dataType">
0 commit comments