bug(cdk/a11y): Observable in HighContrastModeDetector constructor is undefined
See original GitHub issueIs 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:
- Created a year ago
- Reactions:1
- Comments:9 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is relieving to hear. Do you know how to reproduce this?
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.