Skip to content
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

fix(VDatePicker): wrong month can be displayed in header. #19721

Merged
merged 2 commits into from
Apr 30, 2024

Conversation

vincentauger
Copy link
Contributor

@vincentauger vincentauger commented Apr 30, 2024

Description

When using the next/previous control in the VDatePicker, the current logic could sometime pick the wrong month if the current date does not exists. For example, if it is April 30th, 2024 - navigating back to March would work, but going to February would show March again. If the date range is between 1 and 28/29, the picker would work as expected. A similar issues was occuring with VCalendar within the addMonth function.

This is because:
Date.prototype.setMonth()

The current day of month will have an impact on the behavior of this method. Conceptually it will add the number of days given by the current day of the month to the 1st day of the new month specified as the parameter, to return the new date. For example, if the current value is 31st January 2016, calling setMonth with a value of 1 will return 2nd March 2016. This is because in 2016 February had 29 days.

Resolves #19126

Markup:

<template>
  <v-app>
    <v-container>
      <v-date-picker />
      <v-calendar />
    </v-container>

  </v-app>
</template>

<script setup lang="ts">
import {VDatePicker}  from '../src/components/VDatePicker/VDatePicker'
import {VCalendar}  from '../src/labs/VCalendar/VCalendar'
</script>

@johnleider johnleider added this to the v3.6.x milestone Apr 30, 2024
@johnleider johnleider added T: bug Functionality that does not work as intended/expected C: VDatePicker VDatePicker C: VCalendar VCalendar E: date labels Apr 30, 2024
@johnleider johnleider merged commit b0d42c9 into vuetifyjs:master Apr 30, 2024
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VCalendar VCalendar C: VDatePicker VDatePicker E: date T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug Report][3.5.1] Move forward a month in calendar - moves to wrong month
2 participants