Closed talepre closed 2 years ago
If no initial date is supplied through the timestamp
attribute, the datepicker will fallback and set its date to Date.now()
.
When clicking todays date in the table, no datepicker.change
-event will be fired. A datepicker.click.day
-event is however dispatched on every click inside the table. This can be used to set the value of an empty input like this:
// Handle click on today when input is empty
document.addEventListener('datepicker.click.day', function (event) {
if (event.target.id !== 'my-datepicker') return
const input = document.getElementById('my-datepicker-output')
if (input.value === '' && event.target.date.toDateString() === new Date().toDateString()) {
input.value = event.target.date.toLocaleString()
}
})
In core-datepicker v4.0.0, no initial value will dispatch a change-event on selecting today More info and migration guides can be found in 9.0.0
Todays date is marked as selected when no initial date is provided, making it impossible to click it without clicking another date first.