Skip to content

Commit

Permalink
Table | Add browser check to prevent SSR crash
Browse files Browse the repository at this point in the history
  • Loading branch information
cetincakiroglu committed Nov 22, 2023
1 parent dfcc8a6 commit 9cf3b73
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/app/components/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import {
} from './table.interface';
import { Nullable, VoidListener } from 'primeng/ts-helpers';
import { FilterSlashIcon } from 'primeng/icons/filterslash';
import { platformBrowser } from '@angular/platform-browser';

@Injectable()
export class TableService {
Expand Down Expand Up @@ -1298,14 +1299,16 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable
}

ngAfterViewInit() {
if (this.isStateful() && this.resizableColumns) {
this.restoreColumnWidths();
if(isPlatformBrowser(this.platformId)) {
if (this.isStateful() && this.resizableColumns) {
this.restoreColumnWidths();
}
}
}

ngOnChanges(simpleChange: SimpleChanges) {
if (simpleChange.value) {
if (this.isStateful() && !this.stateRestored) {
if (this.isStateful() && !this.stateRestored && isPlatformBrowser(this.platformId)) {
this.restoreState();
}

Expand Down

0 comments on commit 9cf3b73

Please sign in to comment.