1- import { ChangeDetectorRef , Component , Inject , Injector , Input , OnInit } from '@angular/core' ;
2- import { DOCUMENT } from '@angular/common' ;
1+ import { ChangeDetectorRef , Component , Inject , Injector , Input , OnInit , PLATFORM_ID } from '@angular/core' ;
2+ import { DOCUMENT , isPlatformBrowser } from '@angular/common' ;
33
44import { from , Observable } from 'rxjs' ;
55import { concatMap , filter , map , reduce , take } from 'rxjs/operators' ;
@@ -48,6 +48,11 @@ export class ContextMenuComponent implements OnInit {
4848 */
4949 public optionCount = 0 ;
5050
51+ /**
52+ * Flag to check csr rendering
53+ */
54+ browserPlatform = false ;
55+
5156 /**
5257 * Initialize instance variables
5358 *
@@ -58,10 +63,12 @@ export class ContextMenuComponent implements OnInit {
5863 */
5964 constructor (
6065 @Inject ( DOCUMENT ) private _document : Document ,
66+ @Inject ( PLATFORM_ID ) protected platformId : Object ,
6167 private cdr : ChangeDetectorRef ,
6268 private configurationService : ConfigurationDataService ,
6369 private injector : Injector
6470 ) {
71+ this . browserPlatform = isPlatformBrowser ( this . platformId ) ;
6572 }
6673
6774 ngOnInit ( ) : void {
@@ -91,7 +98,7 @@ export class ContextMenuComponent implements OnInit {
9198 private retrieveSelectedContextMenuEntries ( isStandAlone : boolean ) : Observable < any [ ] > {
9299 const list = this . contextMenuObjectType ? getContextMenuEntriesForDSOType ( this . contextMenuObjectType ) : [ ] ;
93100 return from ( list ) . pipe (
94- filter ( ( renderOptions : ContextMenuEntryRenderOptions ) => isNotEmpty ( renderOptions ?. componentRef ) && renderOptions ?. isStandAlone === isStandAlone ) ,
101+ filter ( ( renderOptions : ContextMenuEntryRenderOptions ) => isNotEmpty ( renderOptions ?. componentRef ) && renderOptions ?. isStandAlone === isStandAlone ) ,
95102 map ( ( renderOptions : ContextMenuEntryRenderOptions ) => renderOptions . componentRef ) ,
96103 concatMap ( ( constructor : GenericConstructor < ContextMenuEntryComponent > ) => {
97104 const entryComp : ContextMenuEntryComponent = new constructor ( ) ;
0 commit comments