Skip to content

Month and/or year selecion in DatePicker #4853

@julianobrasil

Description

@julianobrasil

Bug, feature request, or proposal:

Feature

What is the expected behavior?

User being able to select a month in a year, or just a full year number. The component already have a startView attribute. It could have also a view attribute so the component could be configured to show just months of the year, or years.

What is the current behavior?

The user can select a full date only (day, month and year).

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

Although the design docs does mention that will be a date & time option in the future, it does not mention this feature (at least, not explicitly). It's sometimes useful to set the view of a datepicker to allow the selection of just a month or a year. Maybe the problem is related to the date object, that demands a complete date. But it can be left to the developer the control of what is being grabbed from the datepicker, for example:

  • if in year view mode and the user selects july/2017, the component parse it to the first day of july. Something like new Date(2017,6,1);
  • if in "decades" view mode and the user selects the year of 2017, the component parse it to the first day of 2017. Something like new Date(2017,0,1).

The developer would have to know how he configured the component and what kind of information it'll give back to him.

The current state of the component can be used for the user to select a month and a year, but it's too confusing to the user if I put a full calendar to choosing just a month (along with some information like "choose any day in the desired month").

A work around to the lack of this feature is to use a regular mdInput with type="number" (that's the way I use for now, because, after all, representing months as numbers are common knowledge). But it's not a nice way because the user must select (in case of months) the month and the year in separate controls.

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

all

Is there anything else we should know?

no

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/datepickerfeatureThis issue represents a new feature or feature request rather than a bug or bug fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions