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.

FocusMonitor TypeError: Cannot read property 'remove' of undefined (classlist)

See original GitHub issue

While using @angular/cdk ~10.2.2 and @angular/material ^10.2.2 I keep encountering the following error:

TypeError: Cannot read property 'remove' of undefined
    at FocusMonitor._toggleClass (a11y.js:1928)
    at FocusMonitor._setClasses (a11y.js:1957)
    at FocusMonitor.stopMonitoring (a11y.js:1897)
    at MatTooltip.ngOnDestroy (tooltip.js:249)
    at executeOnDestroys (core.js:9070)
    at cleanUpView (core.js:8992)
    at destroyViewTree (core.js:8796)
    at destroyLView (core.js:8945)
    at RootViewRef.destroy (core.js:9679)
    at ComponentRef$1.destroy (core.js:22234)
    at resolvePromise (zone.js:1215)
    at resolvePromise (zone.js:1165)
    at zone.js:1277
    at ZoneDelegate.invokeTask (zone.js:407)
    at Object.onInvokeTask (core.js:27418)
    at ZoneDelegate.invokeTask (zone.js:406)
    at Zone.runTask (zone.js:179)
    at drainMicroTaskQueue (zone.js:583)

The error occurs when I navigate from one page to the other. I noticed the MatTooltip class in the stacktrace, and I’d like to note that while many of the components on the page use tooltips, none were active during the time of navigation (this was instigated by a div with routerLink inside a MatMenu). The error appears to completely break the website, leaving only a background color. Refreshing the page successfully completes the navigation. If any further information is needed, please let me know.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Lolmewncommented, Sep 22, 2020

@crisbeto This does indeed seem to fix the issue. Thanks for your help! I hope this helps to track down any potential bug/issue with the (mis)handling of Angular components.

0reactions
angular-automatic-lock-bot[bot]commented, Oct 23, 2020

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

Having trouble fixing "Uncaught TypeError: Cannot read ...
getElementsByClassName() returns an array (collection). It's the source of the "undefined" and thus .remove() and .classList() are not methods ...
Read more >
cannot read property 'classlist' of undefined javascript
I'm practicing a challenge of making an order checkout page. And I have made a few payment options using the radio button.
Read more >
Error: Cannot read properties of undefined (reading 'remove ...
My issue is that when I press the next button, I get the following error. Error: Cannot read properties of undefined (reading 'remove')....
Read more >
HTML DOM Element classList Property - W3Schools
The classList property is read-only, but you can use the methods listed below, to add, toggle or remove CSS classes from the list: ......
Read more >
Cannot read property 'classList' of null in Gatsbyjs - Reddit
TypeError : Cannot read property 'classList' of null. I am trying to make a navbar that changes color and background color when you...
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