Skip to content

Calendar Does Not Reflect Typed Input with yyyy-MM-dd Format in React Datepicker (v7.5.0) #5471

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

Open
vivekoptimas opened this issue Mar 8, 2025 · 0 comments

Comments

@vivekoptimas
Copy link

vivekoptimas commented Mar 8, 2025

Describe the bug
I encountered a bug when using React Datepicker v7.5.0 with the dateFormat set to yyyy-MM-dd. The expected behavior is that when the user manually types a year, month, or date, the calendar should instantly update based on the input. However, this only works with the yyyy/MM/dd format and fails when using yyyy-MM-dd.

Steps to Reproduce:
Install and use React Datepicker v7.5.0.
Set the dateFormat to yyyy-MM-dd.
Start typing the date manually in the input box. For example:

  • Type: 2008 → The calendar should instantly reflect January 2008.
  • Type: 2008-09 → The calendar should instantly reflect September 2008.
  • Type: 2008-09-09 → The calendar should instantly reflect 9th September 2008.

Behavior: The calendar does not update according to the input unless the format is changed to yyyy/MM/dd.

Expected Behavior:
The calendar should reflect the input as you type:

  • Typing 2008 → Calendar should show January 2008.
  • Typing 2008-09 → Calendar should show September 2008.
  • Typing 2008-09-09 → Calendar should show 9th September 2008.

This behavior works perfectly fine when using yyyy/MM/dd but fails with yyyy-MM-dd.

Actual Behavior:
When using yyyy-MM-dd format, the calendar does not instantly update while typing.
However, when using yyyy/MM/dd format, the calendar updates correctly as you type.

Desktop:

  • React Datepicker Version: v7.5.0
  • React Version: 18.2.0
  • OS: windows
  • Browser : chrome
  • Version 133.0.6943.142

Additional Notes:
This behavior seems like a bug in the internal date parser when using the yyyy-MM-dd format.
It is critical for the input field to update the calendar instantly as users type the date.
I am providing a link to the CodeSandbox to reproduce the issue.

https://2t4l85.csb.app/

https://codesandbox.io/p/sandbox/2t4l85

Could you please confirm if this is a bug or expected behavior? If it’s a bug, it would be helpful to have it fixed in upcoming versions as yyyy-MM-dd is widely used in many applications.

Thank you for your time and consideration! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant