feat(datepicker): close datepicker on click outside
This commit is contained in:
parent
cf3682cc27
commit
88a6b85a7e
@ -10,7 +10,8 @@ const DATEPICKER_CONFIG = {
|
||||
locale: 'de', // TODO: hardcoded
|
||||
weekStart: 1, // TODO: hardcoded
|
||||
stayOpen: true, // to prevent the instance from closing when selecting a date before selecting a time
|
||||
dateFormat: 'dd.mm.YYYY', // TODO: hardcoded
|
||||
closeButton: false,
|
||||
dateFormat: 'dd.mm.YYYY', // TODO: hardcoded, get from setting
|
||||
},
|
||||
'datetime-local': {},
|
||||
'date': {
|
||||
@ -49,6 +50,13 @@ export class Datepicker {
|
||||
|
||||
// mark initialized
|
||||
element.classList.add(DATEPICKER_INITIALIZED_CLASS);
|
||||
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
||||
871
package-lock.json
generated
871
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -54,7 +54,7 @@
|
||||
"@babel/plugin-proposal-class-properties": "^7.4.4",
|
||||
"@babel/plugin-proposal-decorators": "^7.4.4",
|
||||
"@babel/preset-env": "^7.4.5",
|
||||
"@commitlint/cli": "^8.0.0",
|
||||
"@commitlint/cli": "^8.1.0",
|
||||
"@commitlint/config-conventional": "^8.0.0",
|
||||
"autoprefixer": "^9.6.0",
|
||||
"babel-core": "^6.26.3",
|
||||
@ -90,7 +90,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"flatpickr": "^4.5.7",
|
||||
"npm": "^6.9.2",
|
||||
"tail.datetime": "^0.4.13"
|
||||
"npm": "^6.10.3",
|
||||
"tail.datetime": "git+https://git@github.com/pytesNET/tail.DateTime.git#master"
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user