Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TargetEvents breaks on SSR #206

Open
adrian-marcelo-gallardo opened this issue Jul 30, 2021 · 1 comment
Open

TargetEvents breaks on SSR #206

adrian-marcelo-gallardo opened this issue Jul 30, 2021 · 1 comment

Comments

@adrian-marcelo-gallardo

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.

@adrian-marcelo-gallardo
Copy link
Author

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant