shlomiassaf / ngrid

A angular grid for the enterprise

Home Page:https://shlomiassaf.github.io/ngrid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TargetEvents breaks on SSR

adrian-marcelo-gallardo opened this issue · comments

What is the expected behavior?

I can compile my SSR/Universal app when using TargetEvents and DetailRow built-in plugins.

What is the current behavior?

navigator is used in this file without checking if the app is running in browser or server.

The problematic line is this: const isOsx = /^mac/.test(navigator.platform.toLowerCase())

It is at the root of the file, so as soon as the module is referenced it starts giving errors (so, this is not something that I can fix from my app with conditional logic).

What are the steps to reproduce?

Providing a StackBlitz reproduction is the best way to share your issue.

StackBlitz starter: stackblitz.com/edit/pebula-ngrid-starter

In mi case, I have a grid which is using a detail-row. As soon as I add PblNgridDetailRowModule to the imports list of the module, the error is thrown (when running on SSR).

Which versions of Angular, CDK, Material, NGrid, OS, TypeScript, browsers are affected?

Angular 12.1.1
CDK 12.1.1
NGrid 4.0.0-alpha.3
Typescript 4.2.4

Is there anything else we should know?

If I modify node_modules and change the problematic line to something like const isOsx = false; then the application runs OK.

A simple solution could be replacing the problematic line with something like this:

const isOsx = /^mac/.test((typeof navigator !== "undefined" ? navigator.platform : "").toLowerCase());