@@ -804,7 +804,8 @@ describe('IgxGrid Component Tests #grid', () => {
804804 IgxGridColumnPercentageWidthComponent ,
805805 IgxGridWrappedInContComponent ,
806806 IgxGridFormattingComponent ,
807- IgxGridFixedContainerHeightComponent
807+ IgxGridFixedContainerHeightComponent ,
808+ IgxGridColumnHeaderAutoSizeComponent
808809 ] ,
809810 imports : [
810811 NoopAnimationsModule , IgxGridModule ]
@@ -1865,6 +1866,23 @@ describe('IgxGrid Component Tests #grid', () => {
18651866
18661867 expect ( grid . columnList . get ( 0 ) . width ) . toBe ( '50%' ) ;
18671868 } ) ;
1869+
1870+ it ( 'should correctly autosize column headers when the grid container has no data and is initially hidden and then shown' , async ( ) => {
1871+ const fix = TestBed . createComponent ( IgxGridColumnHeaderAutoSizeComponent ) ;
1872+ const grid = fix . componentInstance . grid ;
1873+
1874+ //waiting for reqeustAnimationFrame to finish
1875+ await wait ( 17 ) ;
1876+ fix . detectChanges ( ) ;
1877+
1878+ fix . componentInstance . gridContainerHidden = false ;
1879+ await wait ( 17 )
1880+ fix . detectChanges ( )
1881+
1882+ const calcWidth = parseInt ( grid . columnList . first . calcWidth , 10 )
1883+
1884+ expect ( calcWidth ) . not . toBe ( 80 ) ;
1885+ } ) ;
18681886 } ) ;
18691887
18701888 describe ( 'IgxGrid - API methods' , ( ) => {
@@ -2880,6 +2898,36 @@ export class IgxGridDefaultRenderingComponent {
28802898 }
28812899}
28822900
2901+ @Component ( {
2902+ template : `
2903+ <div [hidden]="gridContainerHidden">
2904+ <igx-grid #grid>
2905+ <igx-column
2906+ field="field1"
2907+ header="Field 1 Header"
2908+ width="auto"
2909+ ></igx-column>
2910+ <igx-column
2911+ field="field2"
2912+ header="Field 2 Header"
2913+ width="auto"
2914+ ></igx-column>
2915+ <igx-column
2916+ field="field3"
2917+ header="Field 3 Header"
2918+ width="auto"
2919+ ></igx-column>
2920+ </igx-grid>
2921+ </div>` ,
2922+ } )
2923+ export class IgxGridColumnHeaderAutoSizeComponent {
2924+ @ViewChild ( 'grid' , { read : IgxGridComponent , static : true } )
2925+ public grid : IgxGridComponent ;
2926+
2927+ public gridContainerHidden = true ;
2928+
2929+ }
2930+
28832931@Component ( {
28842932 template : `<igx-grid #grid [data]="data" [width]="'500px'" (columnInit)="initColumns($event)">
28852933 <igx-column *ngFor="let col of columns" [field]="col.key" [header]="col.key" [dataType]="col.dataType">
0 commit comments