components icon indicating copy to clipboard operation
components copied to clipboard

Make year selectable in date picker

Open mschering opened this issue 9 years ago • 35 comments

Bug, feature request, or proposal:

feature request

What is the expected behavior?

The year should be selectable from a dropdown list.

What is the current behavior?

The year can only be changed with the previous and next button.

What are the steps to reproduce?

See demo: https://material.angular.io/components/datepicker/examples

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

Entering birthdays is very cumbersome. You have to click previous a lot for old people :)

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

Material 2.0

mschering avatar Jul 18 '17 14:07 mschering

I also think that there are serious usability issues with Datepicker. It works great when the user has to select date from current month or from month of the same year. I showed a form with datepicker to few people and ask them to select a date from past years for example Oct 15, 1995. I found them struggling with changing the Year. Most of them used the arrows in month view to go back which irritates user if they have to go back few years.

naveedahmed1 avatar Jul 18 '17 15:07 naveedahmed1

It's already being tracked: #4853.

Edit: Oh, sorry, it's a different request. Material Design Specs says something nice for mobile (image bellow) but doesn't say much for desktops (but the recommendation to use segmented dropdown buttons, which matches @mschering's request).

image

image

julianobrasil avatar Jul 18 '17 17:07 julianobrasil

+1

jonsamwell avatar Aug 08 '17 13:08 jonsamwell

+1

elmoyeldo avatar Aug 10 '17 16:08 elmoyeldo

@mmalerba is there any update on this? should we expect it to be included in next release?

naveedahmed1 avatar Aug 10 '17 17:08 naveedahmed1

I'm probably not going to have time to work on this for the next month or two, I have a lot of other things currently on my plate.

mmalerba avatar Aug 10 '17 17:08 mmalerba

without this feature, date picker is not usable because for the birthday, if user age is 35, he/she should press prev year button 35 times 😨

mahmood-sajjadi avatar Aug 13 '17 11:08 mahmood-sajjadi

+1

erikhaug avatar Sep 01 '17 11:09 erikhaug

We really need this! Current datepicker isn't usable in most cases. Please consider this feature as important.

wiekonek avatar Sep 06 '17 13:09 wiekonek

The same concern for a birthday. Our users 18 to 60+ yrs old.

agnislav avatar Sep 12 '17 14:09 agnislav

Hey @agnislav I have the same issue and until we get the year select implemented I at least was able to work with the min/max dates to minimize the year clicking based on if:

  1. 18 years ago from today is the youngest a user can be
  2. user must be under 100 years old
startAt: Date;
minDate = new Date(Date.now());
maxDate = new Date(Date.now());
startDate: Date;
datepickerDisabled: boolean;
date: Date;


ngOnInit() {
    // setting the min date and thus the max birth date allowing < 100 year old choosable birthdate
    this.minDate.setDate( this.minDate.getDate() );
    this.minDate.setFullYear( this.minDate.getFullYear() - 100 );
        
    // setting the calendar's start date and youngest birth dates for > 18 years old
    this.maxDate.setDate( this.maxDate.getDate() );
    this.maxDate.setFullYear( this.maxDate.getFullYear() - 18 );
    this.startDate = this.maxDate;
}

<md-input-container>
    <input mdInput [mdDatepicker]="birthDatePicker" formControlName="birthDate" placeholder="birthdate" [min]="minDate" [max]="maxDate">
    <md-datepicker-toggle mdSuffix [for]="birthDatePicker"></md-datepicker-toggle>
    <md-datepicker #birthDatePicker startView="year" [startAt]="startDate"></md-datepicker>
    <md-error *ngIf="form.controls['birthDate'].hasError('mdDatepickerMin') && form.controls['birthDate'].touched">You can't be over 100 years old</md-error>                
    <md-error *ngIf="form.controls['birthDate'].hasError('mdDatepickerMax') && form.controls['birthDate'].touched">Users must be at least 18 years old</md-error>                
</md-input-container>

Maybe someone can help optimize this? And at least the user will begin at the 18th year and cannot click back to a date that would make them over 100 years old.

BenRacicot avatar Sep 12 '17 17:09 BenRacicot

+1 for this feature Almost unusable for Date of births

vaibhavrtk avatar Sep 13 '17 12:09 vaibhavrtk

It's a shame, I like it but I won't be using it until this gets implemented!

robert-skinner avatar Sep 25 '17 19:09 robert-skinner

+1 for this Same issue with date of births

ghost avatar Oct 02 '17 18:10 ghost

+1 same issue for date of birth, have to use something else

padilla-jm avatar Oct 09 '17 20:10 padilla-jm

+1 Same issue for that date of birth!.any update from angular team?!

drait avatar Oct 13 '17 15:10 drait

This is one of the most common issue. Is there any date to fix this?

ankitraonka avatar Oct 16 '17 07:10 ankitraonka

Came into this problem today too to implement a birth date picker. I'll give it a look but it will probably be way over my skill level to implement it :)

Lakston avatar Oct 26 '17 15:10 Lakston

@mmalerba any updates?

ankitraonka avatar Oct 31 '17 16:10 ankitraonka

up-ing the priority, I know it's painful without this, I'll try to work on it as soon as I have the time

mmalerba avatar Oct 31 '17 17:10 mmalerba