Skip to content

Commit 1b8df92

Browse files
authored
Merge branch 'master' into mdragnev/fix-6467-master
2 parents e9eb7fc + 10ddeef commit 1b8df92

File tree

11 files changed

+58
-96
lines changed

11 files changed

+58
-96
lines changed

projects/igniteui-angular/src/lib/grids/columns/column.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ export class IgxColumnComponent implements AfterContentInit {
17781778
const colWidth = this.width;
17791779
const isPercentageWidth = colWidth && typeof colWidth === 'string' && colWidth.indexOf('%') !== -1;
17801780
if (isPercentageWidth) {
1781-
this._calcWidth = parseInt(colWidth, 10) / 100 * (grid.calcWidth - grid.featureColumnsWidth);
1781+
this._calcWidth = parseInt(colWidth, 10) / 100 * (grid.calcWidth - grid.featureColumnsWidth());
17821782
} else if (!colWidth) {
17831783
// no width
17841784
this._calcWidth = this.defaultWidth || grid.getPossibleColumnWidth();

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,6 +2834,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
28342834
private _unpinnedWidth = NaN;
28352835
private _visibleColumns = [];
28362836
private _columnGroups = false;
2837+
protected _headerFeaturesWidth = NaN;
28372838

28382839
private _columnWidth: string;
28392840

@@ -3089,10 +3090,11 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
30893090
});
30903091

30913092
this.verticalScrollContainer.onContentSizeChange.pipe(destructor, filter(() => !this._init)).subscribe(($event) => {
3092-
this.calculateGridSizes();
3093+
this.calculateGridSizes(false);
30933094
});
30943095

30953096
this.onDensityChanged.pipe(destructor).subscribe(() => {
3097+
this._headerFeaturesWidth = NaN;
30963098
this.summaryService.summaryHeight = 0;
30973099
this.endEdit(true);
30983100
this.cdr.markForCheck();
@@ -3171,7 +3173,10 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
31713173
* @hidden
31723174
* @internal
31733175
*/
3174-
public resetCaches() {
3176+
public resetCaches(recalcFeatureWidth = true) {
3177+
if (recalcFeatureWidth) {
3178+
this._headerFeaturesWidth = NaN;
3179+
}
31753180
this.resetForOfCache();
31763181
this.resetColumnsCaches();
31773182
this.resetColumnCollections();
@@ -3436,17 +3441,26 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
34363441
/**
34373442
* @hidden
34383443
* Gets the combined width of the columns that are specific to the enabled grid features. They are fixed.
3439-
* TODO: Update for Angular 8. Calling parent class getter using super is not supported for now.
34403444
*/
3441-
public get featureColumnsWidth() {
3442-
return this.getFeatureColumnsWidth();
3445+
public featureColumnsWidth(expander?: ElementRef) {
3446+
if (Number.isNaN(this._headerFeaturesWidth)) {
3447+
const rowSelectArea = this.headerSelectorContainer ?
3448+
this.headerSelectorContainer.nativeElement.getBoundingClientRect().width : 0;
3449+
const rowDragArea = this.rowDraggable && this.headerDragContainer ?
3450+
this.headerDragContainer.nativeElement.getBoundingClientRect().width : 0;
3451+
const groupableArea = this.headerGroupContainer ?
3452+
this.headerGroupContainer.nativeElement.getBoundingClientRect().width : 0;
3453+
const expanderWidth = expander ? expander.nativeElement.getBoundingClientRect().width : 0;
3454+
this._headerFeaturesWidth = rowSelectArea + rowDragArea + groupableArea + expanderWidth;
3455+
}
3456+
return this._headerFeaturesWidth;
34433457
}
34443458

34453459
/**
34463460
* @hidden
34473461
*/
34483462
get summariesMargin() {
3449-
return this.featureColumnsWidth;
3463+
return this.featureColumnsWidth();
34503464
}
34513465

34523466
/**
@@ -4627,11 +4641,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
46274641
parseInt(this.document.defaultView.getComputedStyle(this.nativeElement).getPropertyValue('width'), 10);
46284642
}
46294643

4630-
computedWidth -= this.getFeatureColumnsWidth();
4631-
4632-
if (this.showDragIcons) {
4633-
computedWidth -= this.headerDragContainer ? this.headerDragContainer.nativeElement.offsetWidth : 0;
4634-
}
4644+
computedWidth -= this.featureColumnsWidth();
46354645

46364646
const visibleChildColumns = this.visibleColumns.filter(c => !c.columnGroup);
46374647

@@ -4721,7 +4731,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
47214731
return null;
47224732
}
47234733
this.cdr.detectChanges();
4724-
colSum += this.getFeatureColumnsWidth();
4734+
colSum += this.featureColumnsWidth();
47254735
return colSum;
47264736
}
47274737

@@ -4796,7 +4806,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
47964806
/**
47974807
* @hidden
47984808
*/
4799-
protected calculateGridSizes() {
4809+
protected calculateGridSizes(recalcFeatureWidth = true) {
48004810
/*
48014811
TODO: (R.K.) This layered lasagne should be refactored
48024812
ASAP. The reason I have to reset the caches so many times is because
@@ -4805,11 +4815,11 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
48054815
sizing process which of course, uses values from the caches, thus resulting
48064816
in a broken layout.
48074817
*/
4808-
this.resetCaches();
4818+
this.resetCaches(recalcFeatureWidth);
48094819
this.cdr.detectChanges();
48104820
const hasScroll = this.hasVerticalSroll();
48114821
this.calculateGridWidth();
4812-
this.resetCaches();
4822+
this.resetCaches(recalcFeatureWidth);
48134823
this.cdr.detectChanges();
48144824
this.calculateGridHeight();
48154825

@@ -4839,7 +4849,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
48394849
});
48404850
});
48414851
}
4842-
this.resetCaches();
4852+
this.resetCaches(recalcFeatureWidth);
48434853
}
48444854

48454855
private _applyWidthHostBinding() {
@@ -4856,25 +4866,6 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
48564866
this.cdr.markForCheck();
48574867
}
48584868

4859-
4860-
/**
4861-
* @hidden
4862-
* Gets the combined width of the columns that are specific to the enabled grid features. They are fixed.
4863-
* Method used to override the calculations.
4864-
* TODO: Remove for Angular 8. Calling parent class getter using super is not supported for now.
4865-
*/
4866-
public getFeatureColumnsWidth() {
4867-
let width = 0;
4868-
4869-
if (this.isRowSelectable) {
4870-
width += this.headerSelectorContainer ? this.headerSelectorContainer.nativeElement.getBoundingClientRect().width : 0;
4871-
}
4872-
if (this.rowDraggable) {
4873-
width += this.headerDragContainer ? this.headerDragContainer.nativeElement.getBoundingClientRect().width : 0;
4874-
}
4875-
return width;
4876-
}
4877-
48784869
/**
48794870
* Gets calculated width of the pinned area.
48804871
* ```typescript
@@ -4891,7 +4882,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
48914882
sum += parseInt(col.calcWidth, 10);
48924883
}
48934884
}
4894-
sum += this.featureColumnsWidth;
4885+
sum += this.featureColumnsWidth();
48954886

48964887
return sum;
48974888
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ describe('IgxGrid - Row Selection #grid', () => {
650650
grid = fix.componentInstance.grid;
651651
}));
652652

653-
it('Change RowSelection to multiple ', () => {
653+
it('Change RowSelection to multiple ', fakeAsync(() => {
654654
GridSelectionFunctions.verifyHeaderRowHasCheckbox(fix, false, false);
655655
GridSelectionFunctions.verifyRowHasCheckbox(grid.getRowByIndex(0).nativeElement, false, false);
656656

@@ -661,13 +661,15 @@ describe('IgxGrid - Row Selection #grid', () => {
661661

662662
grid.rowSelection = GridSelectionMode.multiple;
663663
fix.detectChanges();
664+
tick(100);
665+
fix.detectChanges();
664666

665667
GridSelectionFunctions.verifyHeaderAndRowCheckBoxesAlignment(grid);
666668
GridSelectionFunctions.verifyRowSelected(grid.getRowByIndex(0), false, false);
667669
GridSelectionFunctions.verifyHeaderRowCheckboxState(fix);
668670
GridSelectionFunctions.verifyHeaderRowHasCheckbox(fix);
669671
GridSelectionFunctions.verifyRowHasCheckbox(grid.getRowByIndex(0).nativeElement);
670-
});
672+
}));
671673
});
672674

673675
describe('RowSelection single', () => {
@@ -1548,7 +1550,7 @@ describe('IgxGrid - Row Selection #grid', () => {
15481550
grid.getColumnByName('ProductID').hasSummary = true;
15491551
fix.detectChanges();
15501552

1551-
expect(grid.summariesMargin).toBe(grid.featureColumnsWidth);
1553+
expect(grid.summariesMargin).toBe(grid.featureColumnsWidth());
15521554
});
15531555

15541556
it('Filtering: Should properly check the header checkbox state when filtering, #2469', () => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,8 +2362,8 @@ describe('IgxGrid - Summaries #grid', () => {
23622362
function verifySummaryRowIndentationByDataRowIndex(fixture, visibleIndex) {
23632363
const summaryRow = GridSummaryFunctions.getSummaryRowByDataRowIndex(fixture, visibleIndex);
23642364
const summaryRowIndentation = summaryRow.query(By.css('.igx-grid__summaries-patch'));
2365-
const expander = fixture.componentInstance.grid.headerGroupContainer;
2366-
expect(summaryRowIndentation.nativeElement.offsetWidth).toEqual(expander.nativeElement.offsetWidth);
2365+
const grid = fixture.componentInstance.grid;
2366+
expect(summaryRowIndentation.nativeElement.offsetWidth).toEqual(grid.featureColumnsWidth());
23672367
}
23682368

23692369
function verifyBaseSummaries(fixture) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@
3333
<div class="igx-grid__tr" role="row" [style.width.px]='calcWidth'>
3434
<span *ngIf="hasMovableColumns && draggedColumn && pinnedColumns.length <= 0"
3535
[igxColumnMovingDrop]="headerContainer" [attr.droppable]="true" id="left"
36-
class="igx-grid__scroll-on-drag-left" [style.left.px]="featureColumnsWidth"></span>
36+
class="igx-grid__scroll-on-drag-left" [style.left.px]="pinnedWidth"></span>
3737
<span *ngIf="hasMovableColumns && draggedColumn && pinnedColumns.length > 0"
3838
[igxColumnMovingDrop]="headerContainer" [attr.droppable]="true" id="left"
3939
class="igx-grid__scroll-on-drag-pinned" [style.left.px]="pinnedWidth"></span>
40-
4140
<ng-container *ngIf="groupingExpressions.length > 0">
4241
<div class="igx-grid__header-indentation igx-grid__row-indentation--level-{{groupingExpressions.length}}"
4342
[ngClass]="{

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,21 +1121,6 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
11211121
return this.groupArea ? this.groupArea.nativeElement.offsetHeight : 0;
11221122
}
11231123

1124-
/**
1125-
* @hidden
1126-
* Gets the combined width of the columns that are specific to the enabled grid features. They are fixed.
1127-
* TODO: Remove for Angular 8. Calling parent class getter using super is not supported for now.
1128-
*/
1129-
public getFeatureColumnsWidth() {
1130-
let width = super.getFeatureColumnsWidth();
1131-
1132-
if (this.groupingExpressions.length && this.headerGroupContainer) {
1133-
width += this.headerGroupContainer.nativeElement.offsetWidth;
1134-
}
1135-
1136-
return width;
1137-
}
1138-
11391124
/**
11401125
* @hidden
11411126
*/
@@ -1225,6 +1210,7 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
12251210
this.onGroupingDone.pipe(takeUntil(this.destroy$)).subscribe((args) => {
12261211
this.endEdit(true);
12271212
this.summaryService.updateSummaryCache(args);
1213+
this._headerFeaturesWidth = NaN;
12281214
});
12291215
}
12301216

projects/igniteui-angular/src/lib/grids/grid/row-drag.directive.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,12 @@ describe('IgxGrid - Row Drag Tests #grid', () => {
218218
it('should align horizontal scrollbar with first column when column pinning is disabled', fakeAsync(() => {
219219
// has no draggable and selectable rows
220220
grid.width = '400px';
221+
tick(30);
222+
fixture.detectChanges();
221223
grid.rowSelection = GridSelectionMode.none;
222224
grid.rowDraggable = false;
223-
tick();
225+
fixture.detectChanges();
226+
tick(30);
224227
fixture.detectChanges();
225228
let rowSelectElement: DebugElement = fixture.debugElement.query(By.css(CSS_CLASS_SELECTION_CHECKBOX));
226229
let dragIndicatorElement: DebugElement = fixture.debugElement.query(By.css('.' + CSS_CLASS_DRAG_INDICATOR));
@@ -231,7 +234,8 @@ describe('IgxGrid - Row Drag Tests #grid', () => {
231234
// has draggable rows and has no selectable rows
232235
grid.rowSelection = GridSelectionMode.none;
233236
grid.rowDraggable = true;
234-
tick();
237+
fixture.detectChanges();
238+
tick(30);
235239
fixture.detectChanges();
236240
rowSelectElement = fixture.debugElement.query(By.css(CSS_CLASS_SELECTION_CHECKBOX));
237241
dragIndicatorElement = fixture.debugElement.query(By.css('.' + CSS_CLASS_DRAG_INDICATOR));

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
<span *ngIf="hasMovableColumns && draggedColumn && pinnedColumns.length > 0"
1212
[igxColumnMovingDrop]="headerContainer" [attr.droppable]="true" id="left"
1313
class="igx-grid__scroll-on-drag-pinned" [style.left.px]="pinnedWidth"></span>
14-
<div #headerHierarchyExpander (click)="toggleAll()" [hidden]='!hasExpandableChildren || !hasVisibleColumns' [ngClass]="{
15-
'igx-grid__hierarchical-expander igx-grid__hierarchical-expander--header': hasExpandableChildren,
16-
'igx-grid__hierarchical-expander--push': filteringService.isFilterRowVisible,
17-
'igx-grid__hierarchical-expander--no-border': isRowSelectable || rowDraggable
18-
}">
14+
<div #headerHierarchyExpander (click)="toggleAll()" [hidden]='!hasExpandableChildren || !hasVisibleColumns' [ngClass]="{
15+
'igx-grid__hierarchical-expander igx-grid__hierarchical-expander--header': hasExpandableChildren,
16+
'igx-grid__hierarchical-expander--push': filteringService.isFilterRowVisible,
17+
'igx-grid__hierarchical-expander--no-border': isRowSelectable || rowDraggable
18+
}">
1919
<ng-container *ngTemplateOutlet="iconTemplate; context: { $implicit: this }"></ng-container>
2020
</div>
2121
<ng-container *ngIf="rowDraggable">

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

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
416416
super.ngAfterContentInit();
417417
}
418418

419+
/** @hidden */
420+
public featureColumnsWidth() {
421+
return super.featureColumnsWidth(this.headerHierarchyExpander);
422+
}
423+
419424
/**
420425
* @hidden
421426
*/
@@ -452,7 +457,7 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
452457
});
453458
this.columnList.reset(topCols);
454459
if (recalcColSizes && this.columnList.length !== colLength) {
455-
this.calculateGridSizes();
460+
this.calculateGridSizes(false);
456461
}
457462
}
458463
}
@@ -499,32 +504,6 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
499504
}
500505
}
501506

502-
/**
503-
* @hidden
504-
* Gets the combined width of the columns that are specific to the enabled grid features. They are fixed.
505-
* TODO: Remove for Angular 8. Calling parent class getter using super is not supported for now.
506-
*/
507-
public getFeatureColumnsWidth() {
508-
let width = super.getFeatureColumnsWidth();
509-
510-
if (this.hasExpandableChildren) {
511-
width += this.headerHierarchyExpander.nativeElement.offsetWidth || this.getDefaultExpanderWidth();
512-
}
513-
514-
return width;
515-
}
516-
517-
private getDefaultExpanderWidth(): number {
518-
switch (this.displayDensity) {
519-
case DisplayDensity.cosy:
520-
return 57;
521-
case DisplayDensity.compact:
522-
return 49;
523-
default:
524-
return 72;
525-
}
526-
}
527-
528507
/**
529508
* @hidden
530509
*/

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,14 @@ describe('IgxHierarchicalGrid Integration #hGrid', () => {
498498

499499
it('should render summaries for column inside a column group.', fakeAsync(/** row toggle rAF */() => {
500500
fixture.componentInstance.rowIsland.childColumns.first.hasSummary = false;
501+
tick();
501502
fixture.detectChanges();
502503
fixture.componentInstance.rowIsland.childColumns.last.hasSummary = true;
504+
tick();
503505
fixture.detectChanges();
504506

505507
(hierarchicalGrid.dataRowList.toArray()[0].nativeElement.children[0] as HTMLElement).click();
508+
tick();
506509
fixture.detectChanges();
507510

508511
const childGrids = fixture.debugElement.queryAll(By.css('igx-child-grid-row'));

0 commit comments

Comments
 (0)