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.

[mdDatepickerToggle] still opening datepicker when input is disabled

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
willshowellcommented, Jul 26, 2017

You can also just disable the button

<button mdSuffix [disabled]="myForm.get('estimatedApplicationDate').disabled"
     [mdDatepickerToggle]="estimatedApplicationDateDatepicker">
</button>

I feel like the button shouldn’t be coupled to the form control, but could maybe understand the datepicker doing so.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 6, 2019

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

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 >

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