Vuepic / vue-datepicker

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

Add a text change event which triggers when the user writes something in text-input mode #906

Open RaulRohjans opened 4 weeks ago

RaulRohjans commented 4 weeks ago

Is your feature request related to a problem? Please describe. I'm trying to implement a system where the value of the datepicker is the current date/time on the blur event, if there is no modelValue. Something like the following:

            onUnfocus() {
                if(this.model) return

                const dateNow = new Date()
                if(this.format === 'time')
                    return this.model = {
                        hours: dateNow.getHours(),
                        minutes: dateNow.getMinutes()
                    }

                this.model = dateNow.toString()
            }

The issue is that the update:modelValue event is only triggered with the user releases the focus of the datetime picker, and the if model is null because the picker is initially empty and the user starts writing something and releases focus, their text gets replaced with the current date.

Describe the solution you'd like An easy way to fix this is to have access to the value of the text-input and check if that's empty instead of the model. Could be done through a text-change event.

Describe alternatives you've considered Currently I have no alternative to overcome this problem.

Additional context None