Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datepicker min attribute - dates before min dates are still available. Validation works #5065

Closed
vmachacek opened this issue Jun 11, 2017 · 11 comments · Fixed by #5131
Closed
Assignees
Labels
P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful

Comments

@vmachacek
Copy link

vmachacek commented Jun 11, 2017

Bug, feature request, or proposal:

Bug

What is the expected behavior?

When I set 'min' on a datepicker I want to see disabled all dates before that

What is the current behavior?

The dates which are in past from min date are not disabled

What are the steps to reproduce?

Set the min date for datepicker, and previous dates are still available from UI, validation will still work.

What is the use-case or motivation for changing an existing behavior?

The min attribute is useless for UI, the validation still works

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

I'm using https://github.com/angular/material2-builds.git repo

Is there anything else we should know?

I was flowing the #4725 and used the material2-builds repository, but another problem occurred. This issue.

@vmachacek vmachacek changed the title datepicker - dates before min dates are still available. Validation works Datepicker min attribute - dates before min dates are still available. Validation works Jun 11, 2017
@willshowell
Copy link
Contributor

Plunker? Seems to be working fine here

https://plnkr.co/edit/QKBR2ftpbZALDfWC0Uuo?p=preview

@vmachacek
Copy link
Author

Hello, I don't think you are using same repo for angular material https://github.com/angular/material2-builds.git

@willshowell
Copy link
Contributor

Sorry, you're right I was using the latest beta release.

min is working @ 1f93cdb
min is broken @ 28d2ddd

Therefore it looks like the regression was introduced via #4370

cc @mmalerba

@willshowell
Copy link
Contributor

@vmachacek there are several other datepicker bugs due to that PR. I posted them as a comment #4370 (comment) and reposting here:

  1. Unable to start in year view
  2. Start at date has no effect
  3. "Prev month" button initially enabled when min date in current month
  4. When setting min/max dates within current month, all days are enabled until month view is refreshed
  5. Active date is not highlighted until month view is refreshed

@jelbourn
Copy link
Member

@willshowell do you have a reproduction? When I try this in our dev environment it works fine. I also don't see how adding an extra change detection pass would cause any behavior change.

@willshowell
Copy link
Contributor

@jelbourn Weird, I was running it locally too and still seeing this issue. Here's a plunker using the latest material2-build

http://plnkr.co/edit/0iqcOvTy2aZWmIDqyo5t?p=preview

@jelbourn jelbourn added the P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful label Jun 13, 2017
@jelbourn jelbourn self-assigned this Jun 13, 2017
@jelbourn
Copy link
Member

I see the issue now. The initial round of change detection makes Angular think that the component doesn't need another when the datepicker property of DatepickerContent is changed.

@willshowell
Copy link
Contributor

@jelbourn additionally, the entrance animation of the datepicker in touchUi mode stopped working due to that commit.

Working @ 1f93cdb: Plunker
Broken @ 28d2ddd: Plunker

@MeghnathDas
Copy link

Using the following simple code max date is working fine but I could not achieve the min date functionality:
Html Code:

<input matInput [matDatepicker]="picker" placeholder="Choose a date" [min]="startDate" [max]="endDate">
<mat-datepicker-toggle matSuffix [for]="picker">
<mat-datepicker #picker>

Ts Code:
this.minDateValue = new Date(1900, 1, 1);
this.maxDateValue = new Date();

@saravanacs
Copy link

Using typescript and Angular Material Datepicker is validation check date of birth in 18 years from current year. Please tell me anyone, how to develop this

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful
Projects
None yet
5 participants