Provided solutions did not work on my browser, since blur event is not triggered when the picker is closed, and change event was triggered before I remove change event from the input.
Not the ideal solution, since it relies on time, but does the work, as far as I know. (my JS code is in a class, that's why I'mm uysing "this" to store data)
currentDateInput.addEventListener('change', async (event) => {
//wait a bit to check if the user is typing or not
await new Promise((resolve) => setTimeout(resolve, 100));
if (!this.keyPressed) {
this.changeDate(event);
}
});
currentDateInput.addEventListener('keypress', async (event) => {
console.log('keypress');
if (event.keyCode === 13) {
this.keyPressed = false;
this.changeDate(event);
} else {
// disable change event
this.keyPressed = true;
}
});
currentDateInput.addEventListener('blur', async (event) => {
console.log('blur');
this.keyPressed = false;
this.changeDate(event);
});