mirror of
https://github.com/frappe/books.git
synced 2025-01-24 07:38:25 +00:00
Closing dropdown on document click (#91)
* Closing dropdown on document click * Formatting
This commit is contained in:
parent
e5a4464167
commit
85bbd3fa0c
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="dropdown show">
|
||||
<div class="dropdown show" ref="dropdownMenu">
|
||||
<button
|
||||
:id="_uid"
|
||||
class="btn btn-sm btn-light dropdown-toggle"
|
||||
@ -29,6 +29,21 @@ export default {
|
||||
return {
|
||||
isShown: false
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
documentClick(e) {
|
||||
let el = this.$refs.dropdownMenu;
|
||||
let target = e.target;
|
||||
if ((el !== target) && (!el.contains(target))) {
|
||||
this.isShown = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
created () {
|
||||
document.addEventListener('click', this.documentClick);
|
||||
},
|
||||
destroyed () {
|
||||
document.removeEventListener('click', this.documentClick);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@ -44,4 +59,3 @@ $dropdown-link-active-bg: $gray-300;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user