Skip to content

refactor(VDateInput): If multiple, reset model to [] #21299

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

Merged
merged 3 commits into from
May 1, 2025

Conversation

ikushum
Copy link
Member

@ikushum ikushum commented Apr 22, 2025

Description

In multiple mode, when the date is reset/cleared, we should set the model value to [] instead of null

Why is this change required?

In multiple mode, the model value is expected to be an array. Setting it to null would break the expected type.

What problem does it solve?

The change ensures consistent behavior when date is reset/cleared and maintains the correct type for the model value.

Markup:

<template>
  <v-app>
    <v-container>
      {{ date }}
      <v-date-input
        v-model="date"
        clearable
        multiple="range"
        @update:model-value="onUpdateModelValue"
      />
    </v-container>
  </v-app>
</template>

<script setup>
  import { ref } from 'vue'

  const date = ref([])
</script>

@ikushum ikushum added T: enhancement Functionality that enhances existing features C: VDateInput labels Apr 22, 2025
@ikushum ikushum requested review from johnleider and J-Sek April 22, 2025 11:51
@ikushum ikushum self-assigned this Apr 22, 2025
@ikushum ikushum force-pushed the refactor-VDateInput branch from 64231e2 to 1d29cca Compare April 27, 2025 08:50
@ikushum ikushum requested a review from J-Sek April 27, 2025 08:50

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@johnleider
Copy link
Member

This is what I'm working on https://github.com/vuetifyjs/vuetify/pull/21055/files#diff-7f8c8d50ea1b2e7d7e521fcddcaf3e22e82955a715984dba14781eaf8c04910b for. We need a more homogenized way to do this.

@johnleider johnleider requested a review from J-Sek April 28, 2025 15:49
@J-Sek
Copy link
Contributor

J-Sek commented Apr 28, 2025

@johnleider I agree we need similar thing in VSelect, VCombobox, VAutocomplete and probably VFileInput as well, but #21055 goes too far. I have poked it a bit, forced the prop to be a function, but could not force VTextField to emit [] (it is designed to emit string | null). I think it is not the responsibility of VTextField to execute the clearValue().

@ikushum
Copy link
Member Author

ikushum commented Apr 29, 2025

This is what I'm working on #21055 (files) for. We need a more homogenized way to do this.

The prop clear-value is a good "nice to have" feature but even without the prop the components should reset to correct value.

@ikushum ikushum force-pushed the refactor-VDateInput branch from 731058e to afa3754 Compare May 1, 2025 04:55
@johnleider johnleider merged commit 3a9602b into master May 1, 2025
18 checks passed
@johnleider johnleider deleted the refactor-VDateInput branch May 1, 2025 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VDateInput T: enhancement Functionality that enhances existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants