@@ -26,7 +26,7 @@ import { ISortingExpression, SortingDirection } from '../../data-operations/sort
2626import { GRID_SCROLL_CLASS } from '../../test-utils/grid-functions.spec' ;
2727import { AsyncPipe , NgFor , NgIf } from '@angular/common' ;
2828import { IgxPaginatorComponent , IgxPaginatorContentDirective } from '../../paginator/paginator.component' ;
29- import { IGridRowEventArgs , IgxGridFooterComponent , IgxGridRow , IgxGroupByRow , IgxSummaryRow } from '../public_api' ;
29+ import { IGridRowEventArgs , IgxColumnGroupComponent , IgxGridFooterComponent , IgxGridRow , IgxGroupByRow , IgxSummaryRow } from '../public_api' ;
3030import { getComponentSize } from '../../core/utils' ;
3131
3232
@@ -1896,6 +1896,20 @@ describe('IgxGrid Component Tests #grid', () => {
18961896
18971897 expect ( calcWidth ) . not . toBe ( 80 ) ;
18981898 } ) ;
1899+
1900+ it ( 'should correctly autosize column headers inside column groups.' , async ( ) => {
1901+ const fix = TestBed . createComponent ( IgxGridColumnHeaderInGroupAutoSizeComponent ) ;
1902+ const grid = fix . componentInstance . grid ;
1903+ grid . data = [ { field1 : "Test" } ] ;
1904+
1905+ //waiting for reqeustAnimationFrame to finish
1906+ fix . detectChanges ( ) ;
1907+ await wait ( 17 ) ;
1908+ fix . detectChanges ( ) ;
1909+
1910+ const calcWidth = parseInt ( grid . getColumnByName ( "field1" ) . calcWidth ) ;
1911+ expect ( calcWidth ) . toBe ( 126 ) ;
1912+ } ) ;
18991913 } ) ;
19001914
19011915 describe ( 'IgxGrid - API methods' , ( ) => {
@@ -2962,6 +2976,36 @@ export class IgxGridColumnHeaderAutoSizeComponent {
29622976
29632977}
29642978
2979+ @Component ( {
2980+ template : `
2981+ <igx-grid #grid>
2982+ <igx-column-group>
2983+ <igx-column
2984+ field="field1"
2985+ header="Field 1 Header"
2986+ width="auto"
2987+ ></igx-column>
2988+ <igx-column
2989+ field="field2"
2990+ header="Field 2 Header"
2991+ width="auto"
2992+ ></igx-column>
2993+ <igx-column
2994+ field="field3"
2995+ header="Field 3 Header"
2996+ width="auto"
2997+ ></igx-column>
2998+ </igx-column-group>
2999+ </igx-grid>` ,
3000+ standalone : true ,
3001+ imports : [ IgxGridComponent , IgxColumnComponent , IgxColumnGroupComponent ]
3002+
3003+ } )
3004+ export class IgxGridColumnHeaderInGroupAutoSizeComponent {
3005+ @ViewChild ( 'grid' , { read : IgxGridComponent , static : true } )
3006+ public grid : IgxGridComponent ;
3007+ }
3008+
29653009@Component ( {
29663010 template : `<igx-grid #grid [data]="data" [width]="'500px'" (columnInit)="initColumns($event)">
29673011 <igx-column *ngFor="let col of columns" [field]="col.key" [header]="col.key" [dataType]="col.dataType">
0 commit comments