Skip to content

Commit

Permalink
fix(datagrid): check visibility for calculations (backport to 16.x) (#…
Browse files Browse the repository at this point in the history
…1578)

Backport of #1577

---------

Co-authored-by: GitHub <noreply@github.com>
  • Loading branch information
dtsanevmw and web-flow authored Oct 2, 2024
1 parent 2c5aa4c commit cf5ed3b
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion projects/angular/clarity.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5236,7 +5236,7 @@ export class ÇlrDatagridHeaderRenderer implements OnDestroy {

// @public (undocumented)
export class ÇlrDatagridMainRenderer implements AfterContentInit, AfterViewInit, AfterViewChecked, OnDestroy {
constructor(organizer: DatagridRenderOrganizer, items: Items, page: Page, domAdapter: DomAdapter, el: ElementRef, renderer: Renderer2, detailService: DetailService, tableSizeService: TableSizeService, columnsService: ColumnsService, ngZone: NgZone, keyNavigation: KeyNavigationGridController);
constructor(datagrid: ClrDatagrid, organizer: DatagridRenderOrganizer, items: Items, page: Page, domAdapter: DomAdapter, el: ElementRef, renderer: Renderer2, detailService: DetailService, tableSizeService: TableSizeService, columnsService: ColumnsService, ngZone: NgZone, keyNavigation: KeyNavigationGridController);
// (undocumented)
ngAfterContentInit(): void;
// (undocumented)
Expand Down
15 changes: 14 additions & 1 deletion projects/angular/src/data/datagrid/render/main-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
import { Subscription } from 'rxjs';

import { DomAdapter } from '../../../utils/dom-adapter/dom-adapter';
import { ClrDatagrid } from '../datagrid';
import { DatagridColumnChanges } from '../enums/column-changes.enum';
import { DatagridRenderStep } from '../enums/render-step.enum';
import { ColumnStateDiff } from '../interfaces/column-state.interface';
Expand Down Expand Up @@ -68,6 +69,7 @@ export class DatagridMainRenderer implements AfterContentInit, AfterViewInit, Af
private columnsSizesStable = false;

constructor(
private datagrid: ClrDatagrid,
private organizer: DatagridRenderOrganizer,
private items: Items,
private page: Page,
Expand Down Expand Up @@ -121,7 +123,8 @@ export class DatagridMainRenderer implements AfterContentInit, AfterViewInit, Af
}

ngAfterViewChecked() {
if (this.shouldStabilizeColumns) {
const datagridIsVisible = this.checkAndUpdateVisibility();
if (this.shouldStabilizeColumns && datagridIsVisible) {
this.stabilizeColumns();
}
if (this.shouldComputeHeight()) {
Expand Down Expand Up @@ -281,4 +284,14 @@ export class DatagridMainRenderer implements AfterContentInit, AfterViewInit, Af
this.columnsSizesStable = true;
}
}

private checkAndUpdateVisibility() {
if (this.el.nativeElement.offsetParent) {
// this.datagrid.datagrid.nativeElement.style.visibility = 'visible';
return true;
} else {
// this.datagrid.datagrid.nativeElement.style.visibility = 'hidden';
return false;
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/firefox/datagrid/detail--open-detail-core-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/firefox/datagrid/detail--open-detail-ng-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/firefox/datagrid/detail--open-detail-ng-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cf5ed3b

Please # to comment.