[mdDatepickerToggle] still opening datepicker when input is disabled
See original GitHub issueBug, feature request, or proposal:
Bug
What is the expected behavior?
Im using:
- reactive forms
- form builder:
this.myForm = this._fb.group({
...
estimatedApplicationDate: [
{ value: this.data.applicationDate, disabled: true },
[Validators.required]
]
});
and template:
<input mdInput formControlName="estimatedApplicationDate"
[mdDatepicker]="estimatedApplicationDateDatepicker"
placeholder="Date d’application estimée" required
(click)="estimatedApplicationDateDatepicker.open()">
<button mdSuffix [mdDatepickerToggle]="estimatedApplicationDateDatepicker"></button>
<md-datepicker #estimatedApplicationDateDatepicker></md-datepicker>
=> The input is disabled as specified, but I can still open the datepicker panel
What is the current behavior?
The datepicker icon shouldn’t be clickable
What are the steps to reproduce?
Providing a Plunker (or similar) is the best way to get the team to see your issue. Plunker template: https://goo.gl/DlHd6U (template not working, lots of 404)
What is the use-case or motivation for changing an existing behavior?
Consistency i guess
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
- angular ^4.1.0
- @angular/material 2.0.0-beta.8
- OS Windows 10
- browser: Chrome 57
- typescript ~2.3.3
Is there anything else we should know?
Work-around:
<button mdSuffix
[mdDatepickerToggle]="myForm.get('estimatedApplicationDate').disabled? null : estimatedApplicationDateDatepicker">
</button>
I hope this is clear enough… Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Disable (make read-only) text input on mat-datepicker when ...
It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true when you set up...
Read more >Date picker <md-datepicker-toggle> : Disabling input ... - GitHub
If I want to disable input field, so that user cannot enter date manually and I have given the disabled property to the...
Read more >Datepicker in Angular using mat-datepicker | Material Design
Disable mat-datepicker input But we can override disabled property at datepicker and toggle elements. So now we cannot enter date manually but can...
Read more >Datepicker - Angular Material
The datepicker allows users to enter a date either through text input, ... toggle button that gives the user an easy way to...
Read more >Angular Material Datepicker: Complete Guide
The problem is, both the toggle button and the calendar will inherit the disabled state, so the user won't be able to enter...
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
You can also just disable the button
I feel like the button shouldn’t be coupled to the form control, but could maybe understand the datepicker doing so.
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.