stop event propagation on close text button
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
<template v-if="children">
|
<template v-if="children">
|
||||||
<b-nav-item
|
<b-nav-item
|
||||||
v-for="child in text.children" :key="child.id"
|
v-for="child in text.children" :key="child.id"
|
||||||
@click="$emit('open', text.id, child.id)"
|
@click="onChildOpen($event, text.id, child.id)"
|
||||||
:active="children.includes(child.id)"
|
:active="children.includes(child.id)"
|
||||||
>
|
>
|
||||||
{{ child.id }}
|
{{ child.id }}
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<b-nav-item>
|
<b-nav-item>
|
||||||
<b-button-close @click="$emit('close', text.id)" />
|
<b-button-close @click="onSelfClose($event, text.id)" />
|
||||||
</b-nav-item>
|
</b-nav-item>
|
||||||
</b-nav>
|
</b-nav>
|
||||||
</template>
|
</template>
|
||||||
@@ -54,6 +54,18 @@ export default {
|
|||||||
|
|
||||||
props: {
|
props: {
|
||||||
children: { type: Array, default: null }
|
children: { type: Array, default: null }
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
onChildOpen (_, id, childId) {
|
||||||
|
this.$emit('open', id, childId)
|
||||||
|
},
|
||||||
|
|
||||||
|
onSelfClose (e, id) {
|
||||||
|
// stop the click event propagation to avoid other listeners to interact with a soon to be deleted element.
|
||||||
|
e.stopPropagation()
|
||||||
|
this.$emit('close', id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user