igniteui-angular icon indicating copy to clipboard operation
igniteui-angular copied to clipboard

igx-grid - should use document.documentElement.clientHeight instead of screen.height to get viewport height.

Open tkiryu opened this issue 8 years ago • 2 comments

Description

I just want to let you know that there is an incorrect code in a logic calculating grid height.

Result

screen.height is not viewport height. https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/grid/grid.component.ts#L933

Please refer to the following link. https://www.quirksmode.org/mobile/viewports.html

So this code would lead to wrong result in calculating grid height when grid parent height is not specified.

Expected result

document.documentElement.clientHeight should be used instead.

const viewPortHeight = document.documentElement.clientHeight;

tkiryu avatar Jun 04 '18 06:06 tkiryu

Actually I was not able to reproduce a situation where element.clientHeight would return null or undefined to verify how the fix works.

hanastasov avatar Jun 06 '18 12:06 hanastasov

@hanastasov, here is a sample. https://stackblitz.com/edit/igx-grid-calc-height-using-screen-height GridComponent is just wrapping igx-grid. This is the situation.

When it is rendered in DOM, render tree is as below.

<app-grid>
  <igx-grid></igx-grid>
</app-grid>

app-grid is a host element, which is inline element by default. So its width and height is zero.

if (!this.nativeElement.parentNode.clientHeight) {

As a result, the if-condition becomes true.

https://stackoverflow.com/questions/48940252/angular-component-host-element-width-and-height-are-0

tkiryu avatar Jun 06 '18 14:06 tkiryu