Skip to content

auto-apply prevents editing date via Backspace when using text-input #1282

Description

@vaibhav-khedekar-webuy

Description

We're seeing an issue when auto-apply is enabled with min-date & max-date and the user add/edit an existing date via keyboard input (Backspace).

After further investigation we were able to reproduce the same behavior using VueDatePicker.

Version : @vuepic/vue-datepicker v12.1.0

To Reproduce

<template>
  <VueDatePicker
    v-model="date"
    auto-apply
    :min-date="minDate"
    :max-date="maxDate"
    :year-range="[minYr, maxYr]"
    :text-input="{
      format: 'dd/MM/yyyy',
      maskFormat: 'DD/MM/YYYY',
      applyOnBlur: true
    }"
    :time-config="{
        'enableTimePicker': false
    }"
  />
</template>

<script setup>
import { ref } from 'vue'
import { VueDatePicker } from '@vuepic/vue-datepicker'
import '@vuepic/vue-datepicker/dist/main.css'

const minYr = 2013
const maxYr = 3026

const minDate = new Date(minYr, 0, 1)

const maxDate = new Date()
maxDate.setFullYear(maxYr)

const date = ref(minDate)
</script>

Steps

  1. Focus the input.
  2. Press Backspace to delete year.
  3. Press Backspace to delete one or more digits.
  4. It will get stuck at / backslash.

Changing minYr to 2027 will resolve bug.

Expected

The input should remain editable and allow to delete / while the user is modifying the date.

Example:

01/01/2013
↓ Backspace
01/01/201_
↓ Backspace
01/01/20__
↓ Backspace
01/01/2___
↓ Backspace
01/01/____
↓ Backspace
01/01_____

Desktop & mobile:

  • Desktop Browser Chrome

Additional Notes

  • Disabling auto-apply makes Backspace/manual editing work as expected.
  • This appears to be related to the interaction between auto-apply and text-input config.

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting triageThe issue is not reviewed by the maintainersbugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions