Skip to content

[mdDatepickerToggle] still opening datepicker when input is disabled #6053

Closed
@merlosy

Description

@merlosy

Bug, 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!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions