Datepicker overflow when setting date to the 31st of a month.

Open
#1,421 4 comments 0 reactions 1 assignee View on GitHub

@sashamilenkovic is already working on this.

Since Jun 17, 2024.

Assessment

This issue has not been assessed yet.

Description

🐛 bug 🔎 reproduction-needed Pro 🟡 priority-2
Reproduction

https://formkit.link/1d9a21fdf2fdc215a426c75ef6085408

Describe the bug

When a datepicker has an initial value set either by a v-model or the value attribute, programmatically setting the day to the 31st of a month overflows the year value to 1904 and sets the day to the 3rd (E.g. Dec 31, 2024 turns to Dec 3, 1904). It runs into no issues when setting to the 30th of a month, only the 31st. However, setting the date a second time will fix the issue and set it correctly in the field.

This issue occurs whether the v-model has been changed or if the node input is changed. This also occurs on Firefox, Edge, and Chrome. I have not tested any other browsers. This also only occurs with months that have 31 days. Months with less than 31 days do not seem to run into this issue. Along with that, it does not occur if there is no initial date provided to the field.

I was able to reproduce the issue in the sandbox. Simply click the buttons to change the date. When clicking the buttons twice, the date will fix itself. My timezone is CST if that matters for native JS Date reasons.

Environment

• OS: Windows 11
• Browser Firefox
• Version 1.6.5 and 0.126.11

Dominant language
TypeScript
Stars
4.8k
Forks
208
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from formkit/formkit

All issues in formkit/formkit

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.