Vuepic / vue-datepicker

Datepicker component for Vue 3
https://vue3datepicker.com
MIT License
1.48k stars 147 forks source link

Empty date is submitted when using text-input and clearable: false. #791

Closed nickvleeuwen closed 6 months ago

nickvleeuwen commented 6 months ago

Describe the bug When im using text-input mode and have everything selected, then use backspace to clear the text, the empty value is submitted. Even when I have the general configuration clearable on false.

To Reproduce Steps to reproduce the behavior:

Create an VueDatepicker as shown below.

<template>
    <VueDatePicker
        :week-numbers="{ type: 'iso' }"
        auto-apply
        v-model="date"
        :enable-time-picker="false"
        :format="format"
        :text-input="{
            selectOnFocus: true,
            format: 'dd-MM-yyyy',
        }"
        :clearable="clearable"
    />
</template>

<script setup>
    const props = defineProps({
        modelValue: String,
        clearable: {
            default: true,
            type: Boolean
        }
    });
    const date = ref(props.modelValue);

    const format = function(date) {
        return moment(date).format('[W]W | DD-MM-YYYY');
    }
</script>

Expected behavior Nothing, it shouldn't submit anything, just like when you type text partially, it only submits if the text is seen as an correct date value.