Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(datagrid): check visibility for calculations (backport to 16.x) #1578

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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