question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERROR TypeError: _this._focusMonitor.monitor

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the current behavior?

I use Angular Universal with Angular 6.

On SSR i get the following error: ERROR TypeError: _this._focusMonitor.monitor is not a function at MatAnchor.MatButton [as constructor] (/home/mylehre_e-mx_at/mylehre/frontend/dist/server.js:176122:29) at new MatAnchor (/home/mylehre_e-mx_at/mylehre/frontend/dist/server.js:176219:23) at createClass (/home/mylehre_e-mx_at/mylehre/frontend/dist/server.js:14025:20) at createDirectiveInstance (/home/mylehre_e-mx_at/mylehre/frontend/dist/server.js:13906:20) at createViewNodes (/home/mylehre_e-mx_at/mylehre/frontend/dist/server.js:15128:36) at callViewAction (/home/mylehre_e-mx_at/mylehre/frontend/dist/server.js:15444:13) at execComponentViewsAction (/home/mylehre_e-mx_at/mylehre/frontend/dist/server.js:15363:13) at createViewNodes (/home/mylehre_e-mx_at/mylehre/frontend/dist/server.js:15156:5) at Object.createEmbeddedView (/home/mylehre_e-mx_at/mylehre/frontend/dist/server.js:15036:5) at TemplateRef_.createEmbeddedView (/home/mylehre_e-mx_at/mylehre/frontend/dist/server.js:13621:38)

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

Angular = 6.0.2, Material = 6.0.2 OS = Ubuntu 16.04 TypeScript = 2.7.2

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
fvoskacommented, May 24, 2018

This seems to be an issue with the way FocusMonitor is provided: https://github.com/angular/material2/blob/37193d823bf0ca205e187273af80c4597b8f2d86/src/cdk/a11y/focus-monitor/focus-monitor.ts#L40

In Angular 6 there is a new way of providing services, by using treeshakeable operator @Injectable({providedIn: 'root'}). This works fine in the browser. However, it does not seem to work correctly at all times with lazy-loaded modules and SSR / universal.

Temporary solution is to provide FocusMonitor in your app manually for server module:

@NgModule({
  imports: [
    ...
  ],
  providers: [
    FocusMonitor,
  ],
  bootstrap: [...],
})
export class AppServerModule { }

Providing it in AppServerModule is enough, there is no need to provide it in AppModule as it works fine in browser.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 9, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot use Angular Material components with Angular 11
I'm using Angular11 with Angular material 11 as well. As per today, if you run the command: npm install --save @angular/material.
Read more >
API reference for Angular CDK a11y
FocusMonitor. Monitors mouse and keyboard events to determine the cause of focus events. Methods. focusVia ...
Read more >
Monitoring focus with FocusMonitor - StackBlitz
(cdkFocusChange) emits outside NgZone. markForCheck() {. this.ngZone.
Read more >
Angular Components Library: More Than Just Material - SitePen
HTML <div class="example-focus-monitor"> <button ... isOpen" type="button" cdkOverlayOrigin #trigger="cdkOverlayOrigin"> {{isOpen ?
Read more >
(PDF) Analysis of focus errors in lithography using phase-shift ...
We also present results using a new focus monitor based on phase ... focus and depth of focus can be estimated for different...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found