components
components copied to clipboard
bug(MatDatePicker): Improve error message when faulty DateAdapter
trafficstars
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
No response
Description
When you provide a date adapter that does not inherit from Material DateAdapter, you get a very strange error. This might occur when you use different components that also require a (different) date adapter.
Reproduction
Steps to reproduce:
- Stackblitz
- Observe the error.
Expected Behavior
A clear error that the provided DateAdapter is incorrect. This could be done by checking whether localeChanges exists on the date adapter.
Actual Behavior
core.js:6498 ERROR Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading 'subscribe')
TypeError: Cannot read properties of undefined (reading 'subscribe')
at new MatDatepickerInputBase (datepicker.js:3041:1)
at new MatDatepickerInput (datepicker.js:3286:1)
at NodeInjectorFactory.MatDatepickerInput_Factory [as factory]
Environment
- Angular: 14.2.1
- CDK/Material: 14.2.1
- Browser(s): Brave
- Operating System (e.g. Windows, macOS, Ubuntu): macOS