Skip to content

Commit f3131cb

Browse files
fix(disabled-rows): recalculate only if row differs (#73)
fixes the issue where `ngDoCheck` goes into infinte loop when `disableRowCheck` is provided.
1 parent b72a089 commit f3131cb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

projects/ngx-datatable/src/lib/components/datatable.component.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,8 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit, After
850850
* Lifecycle hook that is called when Angular dirty checks a directive.
851851
*/
852852
ngDoCheck(): void {
853-
if (this.rowDiffer.diff(this.rows) || this.disableRowCheck) {
853+
const rowDiffers = this.rowDiffer.diff(this.rows);
854+
if (rowDiffers || this.disableRowCheck) {
854855
if (!this.externalSorting) {
855856
this.sortInternalRows();
856857
} else {
@@ -864,10 +865,13 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit, After
864865
optionalGetterForProp(this.treeToRelation)
865866
);
866867

867-
queueMicrotask(() => {
868-
this.recalculate();
869-
this.cd.markForCheck();
870-
});
868+
if (rowDiffers) {
869+
queueMicrotask(() => {
870+
this.recalculate();
871+
this.cd.markForCheck();
872+
});
873+
}
874+
871875
this.recalculatePages();
872876
this.cd.markForCheck();
873877
}

0 commit comments

Comments
 (0)