Skip to content

Commit 38a2b4c

Browse files
Merge branch '17.2.x' into ganastasov/fix-14539-17.2.x
2 parents 940a7f0 + 4331ca8 commit 38a2b4c

File tree

3 files changed

+87
-9
lines changed

3 files changed

+87
-9
lines changed

projects/igniteui-angular/src/lib/grids/grid/grid.component.spec.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { ISortingExpression, SortingDirection } from '../../data-operations/sort
2626
import { GRID_SCROLL_CLASS } from '../../test-utils/grid-functions.spec';
2727
import { AsyncPipe, NgFor, NgIf } from '@angular/common';
2828
import { 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';
3030
import { 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">

projects/igniteui-angular/src/lib/grids/grid/grid.multi-row-layout.integration.spec.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { By } from '@angular/platform-browser';
44
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
55
import { IgxGridComponent } from './grid.component';
66
import { SampleTestData } from '../../test-utils/sample-test-data.spec';
7-
import { ViewChild, Component } from '@angular/core';
7+
import { ViewChild, Component, DebugElement } from '@angular/core';
88
import { IgxColumnLayoutComponent } from '../columns/column-layout.component';
99
import { wait, UIInteractions } from '../../test-utils/ui-interactions.spec';
1010
import { DefaultSortingStrategy, SortingDirection } from '../../data-operations/sorting-strategy';
@@ -30,6 +30,7 @@ interface ColGroupsType {
3030
describe('IgxGrid - multi-row-layout Integration #grid - ', () => {
3131
let fixture: ComponentFixture<FixtureType>;
3232
let grid: IgxGridComponent;
33+
const COLUMN_HEADER_CLASS = '.igx-grid-th';
3334
configureTestSuite((() => {
3435
return TestBed.configureTestingModule({
3536
imports: [
@@ -896,6 +897,30 @@ describe('IgxGrid - multi-row-layout Integration #grid - ', () => {
896897
expect((grid.verticalScrollContainer.getScroll().children[0] as HTMLElement).offsetHeight -
897898
grid.verticalScrollContainer.getScroll().offsetHeight).toBeLessThanOrEqual(0);
898899
}));
900+
901+
it('should create only one ghost element when dragging a column', async () => {
902+
const headers: DebugElement[] = fixture.debugElement.queryAll(By.css(COLUMN_HEADER_CLASS));
903+
904+
const header = headers[1].nativeElement;
905+
UIInteractions.simulatePointerEvent('pointerdown', header, 50, 50);
906+
await wait();
907+
fixture.detectChanges();
908+
909+
UIInteractions.simulatePointerEvent('pointermove', header, 56, 56);
910+
await wait(50);
911+
fixture.detectChanges();
912+
913+
UIInteractions.simulatePointerEvent('pointermove', header, 230, 30);
914+
await wait();
915+
fixture.detectChanges();
916+
917+
const ghost = fixture.debugElement.queryAll(By.css('.igx-grid__drag-ghost-image'));
918+
expect(ghost.length).toEqual(1);
919+
920+
UIInteractions.simulatePointerEvent('pointerup', header, 230, 30);
921+
await wait();
922+
fixture.detectChanges();
923+
});
899924
});
900925

901926
describe('Resizing', () => {
@@ -1335,6 +1360,19 @@ export class ColumnLayoutGroupingTestComponent extends ColumnLayoutPinningTestCo
13351360
{ field: 'Country', rowStart: 2, colStart: 2, groupable: true },
13361361
{ field: 'Address', rowStart: 3, colStart: 1, colEnd: 3 }
13371362
];
1363+
1364+
public override colGroups: ColGroupsType[] = [
1365+
{
1366+
group: 'group1',
1367+
pinned: true,
1368+
columns: this.cols2
1369+
},
1370+
{
1371+
group: 'group2',
1372+
pinned: false,
1373+
columns: this.cols1
1374+
}
1375+
];
13381376
}
13391377
@Component({
13401378
template: `

projects/igniteui-angular/src/lib/grids/headers/grid-header-group.component.html

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
<igx-grid-header-group *ngIf="!child.hidden" class="igx-grid-thead__subgroup"
1212
[ngClass]="child.headerGroupClasses"
1313
[ngStyle]="child.headerGroupStyles | igxHeaderGroupStyle:child:grid.pipeTrigger"
14-
[column]="child"
15-
[igxColumnMovingDrag]="child"
16-
[ghostHost]="grid.outlet.nativeElement"
17-
[attr.droppable]="true"
18-
[igxColumnMovingDrop]="child">
14+
[column]="child">
1915
</igx-grid-header-group>
2016
</ng-container>
2117
</div>
@@ -70,8 +66,8 @@
7066
[ngClass]="child.headerGroupClasses"
7167
[ngStyle]="child.headerGroupStyles | igxHeaderGroupStyle:child:grid.pipeTrigger"
7268
[column]="child"
73-
[style.min-width]="child.calcWidth | igxHeaderGroupWidth:grid.defaultHeaderGroupMinWidth:grid.hasColumnLayouts"
74-
[style.flex-basis]="child.calcWidth | igxHeaderGroupWidth:grid.defaultHeaderGroupMinWidth:grid.hasColumnLayouts">
69+
[style.min-width]="child.resolvedWidth | igxHeaderGroupWidth:grid.defaultHeaderGroupMinWidth:grid.hasColumnLayouts"
70+
[style.flex-basis]="child.resolvedWidth | igxHeaderGroupWidth:grid.defaultHeaderGroupMinWidth:grid.hasColumnLayouts">
7571
</igx-grid-header-group>
7672
</ng-container>
7773
</div>

0 commit comments

Comments
 (0)