Skip to content

Commit 0638630

Browse files
authored
Merge pull request #7972 from IgniteUI/mkirova/fix-7954-9.1.x
Fix issue with height auto-size when page is zoomed.
2 parents 8303c91 + 0614dfb commit 0638630

File tree

4 files changed

+48
-14
lines changed

4 files changed

+48
-14
lines changed

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

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4635,14 +4635,37 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
46354635
return 0;
46364636
}
46374637

4638+
/**
4639+
* @hidden
4640+
*/
4641+
protected getComputedHeight(elem) {
4642+
return elem.offsetHeight ? parseFloat(this.document.defaultView.getComputedStyle(elem).getPropertyValue('height')) : 0;
4643+
}
4644+
/**
4645+
* @hidden
4646+
*/
4647+
protected getFooterHeight(): number {
4648+
return this.summariesHeight || this.getComputedHeight(this.tfoot.nativeElement);
4649+
}
4650+
/**
4651+
* @hidden
4652+
*/
4653+
protected getTheadRowHeight(): number {
4654+
const height = this.getComputedHeight(this.theadRow.nativeElement);
4655+
return (!this.allowFiltering || (this.allowFiltering && this.filterMode !== FilterMode.quickFilter)) ?
4656+
height - this.getFilterCellHeight() :
4657+
height;
4658+
}
4659+
46384660
/**
46394661
* @hidden
46404662
*/
46414663
protected getToolbarHeight(): number {
46424664
let toolbarHeight = 0;
46434665
if (this.showToolbar && this.toolbarHtml != null) {
4666+
const height = this.getComputedHeight(this.toolbarHtml.nativeElement);
46444667
toolbarHeight = this.toolbarHtml.nativeElement.firstElementChild ?
4645-
this.toolbarHtml.nativeElement.offsetHeight : 0;
4668+
height : 0;
46464669
}
46474670
return toolbarHeight;
46484671
}
@@ -4653,8 +4676,9 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
46534676
protected getPagingFooterHeight(): number {
46544677
let pagingHeight = 0;
46554678
if (this.footer) {
4679+
const height = this.getComputedHeight(this.footer.nativeElement);
46564680
pagingHeight = this.footer.nativeElement.firstElementChild ?
4657-
this.footer.nativeElement.offsetHeight : 0;
4681+
height : 0;
46584682
}
46594683
return pagingHeight;
46604684
}
@@ -4677,17 +4701,15 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
46774701
if (!this._height) {
46784702
return null;
46794703
}
4680-
4681-
const actualTheadRow = (!this.allowFiltering || (this.allowFiltering && this.filterMode !== FilterMode.quickFilter)) ?
4682-
this.theadRow.nativeElement.offsetHeight - this.getFilterCellHeight() :
4683-
this.theadRow.nativeElement.offsetHeight;
4684-
const footerHeight = this.summariesHeight || this.tfoot.nativeElement.offsetHeight - this.tfoot.nativeElement.clientHeight;
4704+
const actualTheadRow = this.getTheadRowHeight();
4705+
const footerHeight = this.getFooterHeight();
46854706
const toolbarHeight = this.getToolbarHeight();
46864707
const pagingHeight = this.getPagingFooterHeight();
46874708
const groupAreaHeight = this.getGroupAreaHeight();
4709+
const scrHeight = this.getComputedHeight(this.scr.nativeElement);
46884710
const renderedHeight = toolbarHeight + actualTheadRow +
46894711
footerHeight + pagingHeight + groupAreaHeight +
4690-
this.scr.nativeElement.clientHeight;
4712+
scrHeight;
46914713

46924714
let gridHeight = 0;
46934715

@@ -4698,13 +4720,13 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
46984720
const bodyHeight = this.getDataBasedBodyHeight();
46994721
return bodyHeight > 0 ? bodyHeight : null;
47004722
}
4701-
gridHeight = parseInt(computed, 10);
4723+
gridHeight = parseFloat(computed);
47024724
} else {
47034725
gridHeight = parseInt(this._height, 10);
47044726
}
47054727
const height = Math.abs(gridHeight - renderedHeight);
47064728

4707-
if (height === 0 || isNaN(gridHeight)) {
4729+
if (Math.round(height) === 0 || isNaN(gridHeight)) {
47084730
const bodyHeight = this.defaultTargetBodyHeight;
47094731
return bodyHeight > 0 ? bodyHeight : null;
47104732
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
906906
* @hidden @internal
907907
*/
908908
protected getGroupAreaHeight(): number {
909-
return this.groupArea ? this.groupArea.nativeElement.offsetHeight : 0;
909+
return this.groupArea ? this.getComputedHeight(this.groupArea.nativeElement) : 0;
910910
}
911911

912912
/**

src/app/grid-column-moving/grid-column-moving.sample.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,14 @@
1010
margin-bottom: 16px;
1111
max-width: 900px;
1212
}
13+
14+
.references {
15+
font-size: .75em;
16+
}
17+
18+
.references > p {
19+
margin: 0;
20+
letter-spacing: initial;
21+
line-height: initial;
22+
font-size: 1em;
23+
}

src/app/grid-column-moving/grid-column-moving.sample.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
[filterMode]="'excelStyleFilter'"
2323
[paging]="false"
2424
[width]="'900px'"
25-
[height]="'800px'">
25+
>
2626
<igx-column *ngFor="let c of columns" [field]="c.field"
2727
[header]="c.field"
2828
[movable]="c.movable"
@@ -37,8 +37,9 @@
3737
[dataType]="c.type">
3838
</igx-column>
3939
<igx-grid-footer>
40-
<div style='height:200px;'>
41-
Test
40+
<div class="references">
41+
<p>Test</p>
42+
<p>Test2</p>
4243
</div>
4344
</igx-grid-footer>
4445
</igx-grid>

0 commit comments

Comments
 (0)