Make sure to only hide the popup when not clicked something inside of it
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
kolaente 2020-11-28 13:07:41 +01:00
parent 85ce39eca0
commit 4a2a0604c2
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 20 additions and 2 deletions

View File

@ -10,7 +10,7 @@
</a>
<transition name="fade">
<div v-if="show" class="datepicker-popup">
<div v-if="show" class="datepicker-popup" ref="datepickerPopup">
<a @click.stop="() => setDate('today')">
<span class="icon">
@ -162,8 +162,26 @@ export default {
this.$emit('input', this.date)
this.$emit('change', this.date)
},
hideDatePopup() {
hideDatePopup(e) {
if(this.show) {
// We walk up the tree to see if any parent of the clicked element is the datepicker element.
// If it is not, we hide the popup. We're doing all this hassle to prevent the popup from closing when
// clicking an element of flatpickr.
let parent = e.target.parentElement
while (parent !== this.$refs.datepickerPopup) {
if(parent.parentElement === null) {
parent = null
break
}
parent = parent.parentElement
}
if(parent === this.$refs.datepickerPopup) {
return
}
this.show = false
this.$emit('close')
}