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.

bug(cdk/a11y): Observable in HighContrastModeDetector constructor is undefined

See original GitHub issue

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

14.0.1

Description

Caused by #25088

This line fails during Karma testing because the observe call before it returns undefined

Stack trace:

    TypeError: Cannot read properties of undefined (reading 'subscribe')
        at new HighContrastModeDetector (node_modules/@angular/cdk/fesm2020/a11y.mjs:2348:40)
        at Object.factory (node_modules/@angular/cdk/fesm2020/a11y.mjs:2406:1)
        at R3Injector.hydrate (node_modules/@angular/core/fesm2020/core.mjs:9258:35)
        at R3Injector.get (node_modules/@angular/core/fesm2020/core.mjs:9146:33)
        at injectInjectorOnly (node_modules/@angular/core/fesm2020/core.mjs:4778:33)
        at Module.ɵɵinject (node_modules/@angular/core/fesm2020/core.mjs:4782:12)
        at Object.useFactory (node_modules/@angular/material/fesm2020/core.mjs:105:1)
        at Object.factory (node_modules/@angular/core/fesm2020/core.mjs:9345:38)
        at R3Injector.hydrate (node_modules/@angular/core/fesm2020/core.mjs:9258:35)
        at R3Injector.get (node_modules/@angular/core/fesm2020/core.mjs:9146:33)

Reproduction

I’m unsure how to completely reproduce, and I’m unable to share the code due to NDA.

Expected Behavior

HighContrastModeDetector successfully constructs

Actual Behavior

Constructor fails on only 2 of my components at the line linked above due to the expected Observable<BreakpointObserver> being undefined.

Environment

  • Angular: Fails on 14.0.2, 14.1.3, and 14.2.0-rc.0
  • CDK/Material: CDK
  • Browser(s): Chrome Headless Karma/Jasmine
  • Operating System (e.g. Windows, macOS, Ubuntu): Amazon Linux 2

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Chris2fourlawcommented, Sep 1, 2022

The same issue after upgrading angular version 13 -> 14.2.0.

This is relieving to hear. Do you know how to reproduce this?

0reactions
angular-automatic-lock-bot[bot]commented, Oct 18, 2022

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

NullInjectorError: No provider for HighContrastModeDetector
In my case , incompatible versions of @angular/cli and @angular/material was causing the error. to solve it : try to upgrade node package ......
Read more >
cannot read properties of undefined (reading 'subscribe') karma
angular/componentsbug(cdk/a11y): Observable in HighContrastModeDetector constructor is undefined#25563. Created 4 months ago.
Read more >
@angular/cdk | Yarn - Package Manager
The Angular team builds and maintains both common UI components and tools to help you build your own custom components. The team maintains...
Read more >
API reference for Angular CDK a11y
import {A11yModule} from '@angular/cdk/a11y'; ... to update the input modality to keyboard, but in general this service's behavior is largely undefined.
Read more >
Narayani Sachdeva
HighContrastModeDetector \n }, {\n type: undefined,\n decorators: [{\n ... observable to emit whenever the form field should be updated.
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