mirror of
https://github.com/bitinflow/ui.git
synced 2026-03-13 13:45:59 +00:00
Fix closing
This commit is contained in:
@@ -28,22 +28,28 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
open: false,
|
||||
close: () => {
|
||||
closeListener: () => {
|
||||
// is clicked outside the dropdown
|
||||
if (!this.$el.contains(event.target)) {
|
||||
this.open = false;
|
||||
this.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
document.addEventListener('click', this.close);
|
||||
document.addEventListener('click', this.closeListener);
|
||||
},
|
||||
|
||||
beforeUnmount() {
|
||||
document.removeEventListener('click', this.close);
|
||||
document.removeEventListener('click', this.closeListener);
|
||||
},
|
||||
|
||||
methods: {
|
||||
close() {
|
||||
this.open = false
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
</div>
|
||||
<div class="w-20 h-18 flex justify-center items-center">
|
||||
<div class="w-1/2 h-11">
|
||||
<bitinflow-dropdown>
|
||||
<bitinflow-dropdown ref="dropdown">
|
||||
<template #menu>
|
||||
<template
|
||||
v-for="option in options"
|
||||
@@ -35,7 +35,7 @@
|
||||
>
|
||||
<bitinflow-dropdown-item
|
||||
:destructive="option.destructive"
|
||||
@click="option.action([item])"
|
||||
@click="optionClick(option)"
|
||||
>
|
||||
<i :class="['fal mr-2', option.icon ? option.icon : 'fa-play']"/>
|
||||
{{ option.label }}
|
||||
@@ -87,6 +87,10 @@ export default {
|
||||
},
|
||||
click() {
|
||||
this.$emit('click');
|
||||
},
|
||||
optionClick(option) {
|
||||
this.$refs.dropdown.close();
|
||||
option.action([this.item])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user