feat(datepicker): close datepicker on escape keydown
This commit is contained in:
parent
88a6b85a7e
commit
0e5707ac9f
@ -51,12 +51,19 @@ export class Datepicker {
|
||||
// mark initialized
|
||||
element.classList.add(DATEPICKER_INITIALIZED_CLASS);
|
||||
|
||||
// close the instance if something other than the instance was clicked (i.e. if the target is not within the datepicker instance and if any previously clicked calendar view was replaced (is not in the window anymore) because it was clicked). YES, I KNOW
|
||||
window.addEventListener('click', event => {
|
||||
// close the instance if something other than the instance was clicked (i.e. if the target is not within the datepicker instance and if any previously clicked calendar view was replaced (is not in the window anymore) because it was clicked). YES, I KNOW
|
||||
if (!this.datepickerInstance.dt.contains(event.target) && window.document.contains(event.target)) {
|
||||
this.datepickerInstance.close();
|
||||
}
|
||||
});
|
||||
|
||||
// close the datepicker on escape keydown events
|
||||
element.addEventListener('keydown', event => {
|
||||
if (event.keyCode === 27) {
|
||||
this.datepickerInstance.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user