Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
404 changes: 268 additions & 136 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { NgTemplateOutlet } from '@angular/common';
import {
booleanAttribute,
ChangeDetectionStrategy,
Component,
computed,
DoCheck,
Expand Down Expand Up @@ -84,7 +83,6 @@ import { ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ARROW_UP, ENTER } from '../../util
</div>
`,
styleUrl: './body-cell.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Removing ChangeDetectionStrategy.OnPush from DataTableBodyCellComponent will cause a severe performance regression.

Since cells are rendered in large numbers and updated frequently (especially during scrolling, sorting, or filtering), using the default change detection strategy means Angular will re-evaluate every cell on every change detection cycle. Keeping OnPush is critical to ensure that only cells with changed inputs are updated, which is vital for maintaining 60fps scrolling performance.

host: {
class: 'datatable-body-cell',
'[class]': 'columnCssClasses()',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { NgTemplateOutlet } from '@angular/common';
import {
booleanAttribute,
ChangeDetectionStrategy,
Component,
computed,
input,
output
} from '@angular/core';
import { booleanAttribute, Component, computed, input, output } from '@angular/core';

import { Group, GroupContext, Row } from '../../types/public.types';
import { DatatableGroupHeaderDirective } from './body-group-header.directive';
Expand Down Expand Up @@ -45,7 +38,6 @@ import { DatatableGroupHeaderDirective } from './body-group-header.directive';
}
`,
styleUrl: './body-group-wrapper.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'datatable-group-wrapper'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
TemplateRef,
ViewContainerRef,
input,
ChangeDetectionStrategy,
booleanAttribute
} from '@angular/core';

Expand All @@ -30,7 +31,7 @@ import { RowOrGroup } from '../../types/public.types';
[ngTemplateOutletContext]="rowContext"
/>
}`,
styleUrl: './body-row-def.component.scss'
changeDetection: ChangeDetectionStrategy.Eager

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

There is no ChangeDetectionStrategy.Eager in Angular. The only available strategies are Default and OnPush. Since Default is the default strategy when changeDetection is omitted, you can simply remove this property.

})
export class DatatableRowDefComponent {
private host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { NgTemplateOutlet } from '@angular/common';
import {
booleanAttribute,
ChangeDetectionStrategy,
Component,
computed,
DoCheck,
Expand Down Expand Up @@ -30,7 +29,6 @@ import { DatatableRowDetailDirective } from '../row-detail/row-detail.directive'
}
`,
styleUrl: './body-row-wrapper.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'datatable-row-wrapper'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
booleanAttribute,
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
computed,
Expand Down Expand Up @@ -59,7 +58,6 @@ import { DataTableBodyCellComponent } from './body-cell.component';
}
`,
styleUrl: './body-row.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Removing ChangeDetectionStrategy.OnPush from DataTableBodyRowComponent will significantly degrade table rendering and scrolling performance.

Rows are the primary container for cells, and change detection at the row level should only trigger when the row data or state actually changes. Reverting to the default change detection strategy will cause unnecessary checks across all rows and cells on every change detection cycle.

host: {
class: 'datatable-body-row',
role: 'row',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { NgTemplateOutlet } from '@angular/common';
import {
booleanAttribute,
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
computed,
Expand Down Expand Up @@ -248,7 +247,6 @@ import { DataTableSummaryRowComponent } from './summary/summary-row.component';
}
`,
styleUrl: './body.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'datatable-body'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import { NgTemplateOutlet } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
computed,
numberAttribute,
input
} from '@angular/core';
import { Component, computed, numberAttribute, input } from '@angular/core';

import { TableColumnInternal } from '../../../types/internal.types';

@Component({
selector: 'ghost-loader',
imports: [NgTemplateOutlet],
templateUrl: './ghost-loader.component.html',
styleUrl: './ghost-loader.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush
styleUrl: './ghost-loader.component.scss'
})
export class DataTableGhostLoaderComponent {
readonly columns = input.required<TableColumnInternal[]>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { Component } from '@angular/core';

@Component({
selector: 'datatable-progress',
Expand All @@ -8,7 +8,6 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
<div class="bar"></div>
</div>
</div>
`,
changeDetection: ChangeDetectionStrategy.OnPush
`
})
export class ProgressBarComponent {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
ChangeDetectionStrategy,
Component,
inject,
OnDestroy,
Expand All @@ -21,7 +20,6 @@ export interface ScrollEventInternal {
@Component({
selector: 'datatable-scroller',
template: ` <ng-content /> `,
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'datatable-scroll',
'[style.height.px]': 'scrollHeight()'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NgTemplateOutlet } from '@angular/common';
import { Component, computed, input, TemplateRef } from '@angular/core';
import { ChangeDetectionStrategy, Component, computed, input, TemplateRef } from '@angular/core';

import { TableColumnInternal } from '../../../types/internal.types';
import { DataTableBodyRowComponent } from '../body-row.component';
Expand Down Expand Up @@ -48,6 +48,7 @@ const noopSumFunc = (cells: any[]): void => {
}
`,
styleUrl: './summary-row.component.scss',
changeDetection: ChangeDetectionStrategy.Eager,
Comment thread
spike-rabbit marked this conversation as resolved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we just published it without Eager, without any issues. So you can just remove OnPush everywhere without adding Eager

host: {
class: 'datatable-summary-row'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
AfterViewInit,
afterNextRender,
booleanAttribute,
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
computed,
Expand Down Expand Up @@ -97,7 +96,6 @@ import { DatatableRowDetailDirective } from './row-detail/row-detail.directive';
useExisting: DatatableComponent
}
],
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'ngx-datatable',
'[class.fixed-header]': '_isFixedHeader()',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NgTemplateOutlet } from '@angular/common';
import { ChangeDetectionStrategy, Component, computed, input, output, Signal } from '@angular/core';
import { Component, computed, input, output, Signal } from '@angular/core';

import { FooterContext, PagerPageEvent } from '../../types/public.types';
import { DatatableFooterDirective } from './footer.directive';
Expand Down Expand Up @@ -34,7 +34,6 @@ import { DatatablePagerComponent } from './pager.component';
</div>
`,
styleUrl: './footer.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'datatable-footer'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';
import { Component, computed, inject } from '@angular/core';

import { Page } from '../../types/internal.types';
import { DATATABLE_COMPONENT_TOKEN } from '../../utils/table-token';
Expand Down Expand Up @@ -87,7 +87,6 @@ import { DatatableComponent } from '../datatable.component';
</ul>
`,
styleUrl: './pager.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'datatable-pager'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { NgTemplateOutlet } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
ElementRef,
HostListener,
Expand Down Expand Up @@ -81,7 +80,6 @@ import { nextSortDir } from '../../utils/sort';
}
`,
styleUrl: './header-cell.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'datatable-header-cell',
'[attr.resizeable]': 'showResizeHandle()',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
ChangeDetectionStrategy,
Component,
computed,
input,
output,
TemplateRef
} from '@angular/core';
import { Component, computed, input, output, TemplateRef } from '@angular/core';

import { DatatableDraggableDirective } from '../../directives/datatable-draggable.directive';
import { OrderableDirective } from '../../directives/orderable.directive';
Expand Down Expand Up @@ -80,7 +73,6 @@ import { DataTableHeaderCellComponent } from './header-cell.component';
</div>
`,
styleUrl: './header.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'datatable-header',
'[style.height.px]': 'headerHeight()'
Expand Down
5 changes: 3 additions & 2 deletions projects/stackblitz/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, provideZoneChangeDetection } from '@angular/core';
import { ChangeDetectionStrategy, Component, provideZoneChangeDetection } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { DataTableColumnDirective, DatatableComponent } from '@siemens/ngx-datatable';

Expand All @@ -20,7 +20,8 @@ import { DataTableColumnDirective, DatatableComponent } from '@siemens/ngx-datat
<ngx-datatable-column name="field1" />
<ngx-datatable-column name="field2" />
</ngx-datatable>
`
`,
changeDetection: ChangeDetectionStrategy.Eager
})
export class App {
mockData = new Array(100).fill(0).map((_, i) => ({
Expand Down
5 changes: 3 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HashLocationStrategy, Location, LocationStrategy } from '@angular/common';
import { Component, signal } from '@angular/core';
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { RouterLink, RouterOutlet } from '@angular/router';

import packageInfo from '../../projects/ngx-datatable/package.json';
Expand All @@ -14,7 +14,8 @@ import packageInfo from '../../projects/ngx-datatable/package.json';
provide: LocationStrategy,
useClass: HashLocationStrategy
}
]
],
changeDetection: ChangeDetectionStrategy.Eager
Comment on lines +17 to +18

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

There is no ChangeDetectionStrategy.Eager in Angular. If you want to use the default change detection strategy, you can simply omit the changeDetection property entirely.

  ]

})
export class AppComponent {
version = packageInfo.version;
Expand Down
5 changes: 3 additions & 2 deletions src/app/basic/10k-rows.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, inject, signal, viewChild } from '@angular/core';
import { ChangeDetectionStrategy, Component, inject, signal, viewChild } from '@angular/core';
import { FormsModule } from '@angular/forms';
import {
DataTableColumnCellDirective,
Expand Down Expand Up @@ -74,7 +74,8 @@ import { DataService } from '../data.service';
<ngx-datatable-column name="Row Height" prop="height" [width]="80" />
</ngx-datatable>
</div>
`
`,
changeDetection: ChangeDetectionStrategy.Eager
})
export class TenKRowsComponent {
private dataService = inject(DataService);
Expand Down
5 changes: 3 additions & 2 deletions src/app/basic/bootstrap-theme.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, inject, signal } from '@angular/core';
import { ChangeDetectionStrategy, Component, inject, signal } from '@angular/core';
import { DatatableComponent, TableColumn } from '@siemens/ngx-datatable';

import { Employee } from '../data.model';
Expand Down Expand Up @@ -37,7 +37,8 @@ import { DataService } from '../data.service';
[reorderable]="reorderable"
/>
</div>
`
`,
changeDetection: ChangeDetectionStrategy.Eager
})
export class BootstrapThemeComponent {
private dataService = inject(DataService);
Expand Down
5 changes: 3 additions & 2 deletions src/app/basic/context-menu.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AsyncPipe } from '@angular/common';
import { Component, inject } from '@angular/core';
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { ContextMenuEvent, DatatableComponent, TableColumn } from '@siemens/ngx-datatable';

import { Employee } from '../data.model';
Expand Down Expand Up @@ -54,7 +54,8 @@ import { DataService } from '../data.service';
(tableContextmenu)="onTableContextMenu($event)"
/>
</div>
`
`,
changeDetection: ChangeDetectionStrategy.Eager
})
export class ContextMenuComponent {
protected readonly rows = inject(DataService).load('company.json');
Expand Down
5 changes: 3 additions & 2 deletions src/app/basic/css-classes.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AsyncPipe } from '@angular/common';
import { Component, inject } from '@angular/core';
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { DataTableColumnDirective, DatatableComponent, TableColumn } from '@siemens/ngx-datatable';
import { map } from 'rxjs';

Expand Down Expand Up @@ -36,7 +36,8 @@ import { DataService } from '../data.service';
<ngx-datatable-column name="Age" />
</ngx-datatable>
</div>
`
`,
changeDetection: ChangeDetectionStrategy.Eager
})
export class CssClassesComponent {
protected readonly rows = inject(DataService)
Expand Down
5 changes: 3 additions & 2 deletions src/app/basic/dark-theme.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, inject, signal } from '@angular/core';
import { ChangeDetectionStrategy, Component, inject, signal } from '@angular/core';
import { DatatableComponent, TableColumn } from '@siemens/ngx-datatable';

import { Employee } from '../data.model';
Expand Down Expand Up @@ -36,7 +36,8 @@ import { DataService } from '../data.service';
[reorderable]="reorderable"
/>
</div>
`
`,
changeDetection: ChangeDetectionStrategy.Eager
})
export class DarkThemeComponent {
private dataService = inject(DataService);
Expand Down
5 changes: 3 additions & 2 deletions src/app/basic/disabled.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, inject, signal } from '@angular/core';
import { ChangeDetectionStrategy, Component, inject, signal } from '@angular/core';
import {
DataTableColumnCellDirective,
DataTableColumnDirective,
Expand Down Expand Up @@ -90,7 +90,8 @@ import { DataService } from '../data.service';
</ngx-datatable>
</div>
</div>
`
`,
changeDetection: ChangeDetectionStrategy.Eager
})
export class DisabledComponent {
private dataService = inject(DataService);
Expand Down
5 changes: 3 additions & 2 deletions src/app/basic/dynamic-row-height.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AsyncPipe } from '@angular/common';
import { Component, inject } from '@angular/core';
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { DataTableColumnDirective, DatatableComponent } from '@siemens/ngx-datatable';
import { map } from 'rxjs';

Expand Down Expand Up @@ -36,7 +36,8 @@ import { DataService } from '../data.service';
<ngx-datatable-column name="Row Height" prop="height" />
</ngx-datatable>
</div>
`
`,
changeDetection: ChangeDetectionStrategy.Eager
})
export class DynamicRowHeightComponent {
protected readonly rows = inject(DataService)
Expand Down
Loading
Loading