Skip to content

fix: Prevent DatePicker time input from resetting date to today #72

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Lucaka
Copy link

@Lucaka Lucaka commented Feb 14, 2025

PR Description

Problem Encountered:

When assigning a specific date (e.g., value = new Date('2025-02-14')), manually entering a value in a type="time" <DatePicker> component causes the date to reset to today's date.

Reproduction Example:
<DatePicker v-model:value="value" type="date"></DatePicker> 
<DatePicker v-model:value="value" type="time" format="HH:mm"></DatePicker>
  • Expected: The time input should update only the time while preserving the original date (2025-02-14).
  • Actual: The date is reset to today (new Date()).

Solution in This PR:

  • In PickerInput, when handleChange is triggered, we retain the original date while updating only the time.
  • Instead of using parseDate, which resets the date to today, we ensure that only the time portion is modified.
  • This prevents unexpected date resets and ensures consistent behavior across type="time" inputs.

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

Successfully merging this pull request may close these issues.

1 participant