Skip to content

Auto navigation while typing goes to weird dates #6214

@floriancargoet

Description

@floriancargoet

Describe the bug
When typing a date manually, the calendar try to navigate to the date but partial dates give surprising results and the navigation jumps back & forth.
Even when the date is correct, sometimes the calendar shows an incorrect date.

To Reproduce
Steps to reproduce the behavior:

  1. I'm using the Custom Date Format example: https://reactdatepicker.com/#example-custom-date-format
  2. Type 2021 in the input, it goes to January 2021
  3. Type 2022 in the input, it goes to February 2022
  4. Type 2027 in the input, it goes to July 2027

It looks like the last number of the year is used as the month. I think the view should stay on 1st Jan.

  1. Type 2027/01, it goes to July 2027 (I expect January here)
  2. Add a / to get 2027/01/ and now it goes to January 2027 as expected
  3. Add a 0 to get 2027/01/0 and it goes back to July (I expect to stay on the same view when the date becomes invalid)
  4. Finally add a 1 to get a full date 2027/01/01

Screenshots
If applicable, add screenshots to help explain your problem.

Image Image Image Image

And in my codesandbox, the worst case:

Image

Desktop:

  • OS: MacOS
  • Browser: Chrome
  • Version: 143

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