From 9cf3b73d6a32e40086efabac85a4b4db5787264f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87etin?= <69278826+cetincakiroglu@users.noreply.github.com> Date: Wed, 22 Nov 2023 23:21:06 +0300 Subject: [PATCH] Table | Add browser check to prevent SSR crash --- src/app/components/table/table.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/components/table/table.ts b/src/app/components/table/table.ts index 7085bd28557..31e1c45fb22 100644 --- a/src/app/components/table/table.ts +++ b/src/app/components/table/table.ts @@ -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 { @@ -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(); }