Skip to content

Commit

Permalink
fix(disabled-rows): recalculate only if row differs (#73)
Browse files Browse the repository at this point in the history
fixes the issue where `ngDoCheck` goes into infinte loop when `disableRowCheck` is provided.
  • Loading branch information
chintankavathia authored Jul 24, 2024
1 parent b72a089 commit f3131cb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions projects/ngx-datatable/src/lib/components/datatable.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,8 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit, After
* Lifecycle hook that is called when Angular dirty checks a directive.
*/
ngDoCheck(): void {
if (this.rowDiffer.diff(this.rows) || this.disableRowCheck) {
const rowDiffers = this.rowDiffer.diff(this.rows);
if (rowDiffers || this.disableRowCheck) {
if (!this.externalSorting) {
this.sortInternalRows();
} else {
Expand All @@ -864,10 +865,13 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit, After
optionalGetterForProp(this.treeToRelation)
);

queueMicrotask(() => {
this.recalculate();
this.cd.markForCheck();
});
if (rowDiffers) {
queueMicrotask(() => {
this.recalculate();
this.cd.markForCheck();
});
}

this.recalculatePages();
this.cd.markForCheck();
}
Expand Down

0 comments on commit f3131cb

Please sign in to comment.