Skip to content

Cannot select a month with less days than the current day of the month #6180

Closed
@lvaskys

Description

@lvaskys

Bug, feature request, or proposal:

In the datepicker, when selecting a month using the month picker area, selecting a month with less days than the current day of the month will cause an error to be thrown and the given month will not appear in the datepicker.

What is the expected behavior?

The given month will pop up and allow the user to pick a date within that month.

What is the current behavior?

An error is thrown, and the month does not display and remains on the month picker screen.

Error: Invalid date "31" for month with index "1".
at NativeDateAdapter.Array.concat.NativeDateAdapter.createDate (material.es5.js:4368)
at MdYearView.Array.concat.MdYearView._monthSelected (material.es5.js:19128)
at Object.eval [as handleEvent] (MdYearView.ngfactory.js:19)
at Object.handleEvent (core.es5.js:11997)
at Object.handleEvent (core.es5.js:12721)
at dispatchEvent (core.es5.js:8601)
at core.es5.js:10763
at SafeSubscriber.schedulerFn [as _next] (core.es5.js:3647)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:238)
at SafeSubscriber.next (Subscriber.js:185)

What are the steps to reproduce?

Requirements: Today must be a day of the month where there exists a month with less than the current day's number of days. For example, today (7/31/2017), this error appeared because a user wanted to pick February, but could not because February doesn't have 31 days.

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

  1. Open the date picker
  2. Select the Month-Year in order to get to the month picker.
  3. Select February. An error is thrown and the datepicker screen stays the same.

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

Some users like to use the month-picker rather than scrolling through the months using the left and right carrots and should be able to do so.

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

Angular 4.1.3
Material 2.0.0-beta.8
OS Windows 10
Typescript 2.3.2

Is there anything else we should know?

Metadata

Metadata

Assignees

No one assigned

    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