Close menu on leaf click

pull/345/head
cagataycivici 2020-05-15 18:31:05 +03:00
parent d8718af3f8
commit 0ae04152c1
3 changed files with 6 additions and 6 deletions

View File

@ -6,7 +6,7 @@
<div class="p-menubar-start" v-if="$slots.start"> <div class="p-menubar-start" v-if="$slots.start">
<slot name="start"></slot> <slot name="start"></slot>
</div> </div>
<MenubarSub ref="rootmenu" :model="model" :root="true" :mobileActive="mobileActive"/> <MenubarSub ref="rootmenu" :model="model" :root="true" :mobileActive="mobileActive" @leaf-click="onLeafClick"/>
<div class="p-menubar-custom" v-if="$slots.default"> <div class="p-menubar-custom" v-if="$slots.default">
<slot></slot> <slot></slot>
</div> </div>
@ -61,6 +61,9 @@ export default {
this.outsideClickListener = null; this.outsideClickListener = null;
} }
}, },
onLeafClick() {
this.mobileActive = false;
}
}, },
computed: { computed: {
containerClass() { containerClass() {

View File

@ -116,10 +116,7 @@ export default {
}, },
onLeafClick() { onLeafClick() {
this.activeItem = null; this.activeItem = null;
this.$emit('leaf-click');
if (!this.root) {
this.$emit('leaf-click');
}
}, },
onItemKeyDown(event, item) { onItemKeyDown(event, item) {
let listItem = event.currentTarget.parentElement; let listItem = event.currentTarget.parentElement;

View File

@ -99,7 +99,7 @@ export default {
}); });
} }
if (this.root && item.items) { if (item.items) {
if (this.activeItem && item === this.activeItem) if (this.activeItem && item === this.activeItem)
this.activeItem = null; this.activeItem = null;
else else