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
@ -51,4 +51,4 @@ class Dropdown {
|
|||||||
|
|
||||||
Dropdown.instances = 0;
|
Dropdown.instances = 0;
|
||||||
|
|
||||||
module.exports = Dropdown;
|
module.exports = Dropdown;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="dropdown show">
|
<div class="dropdown show" ref="dropdownMenu">
|
||||||
<button
|
<button
|
||||||
:id="_uid"
|
:id="_uid"
|
||||||
class="btn btn-sm btn-light dropdown-toggle"
|
class="btn btn-sm btn-light dropdown-toggle"
|
||||||
@ -29,7 +29,22 @@ export default {
|
|||||||
return {
|
return {
|
||||||
isShown: false
|
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>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@ -44,4 +59,3 @@ $dropdown-link-active-bg: $gray-300;
|
|||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
@ -35,4 +35,4 @@ export default function installFrappePlugin(Vue) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user