Skip to content

Commit

Permalink
fix: close tera-context-menu after selection (#1296)
Browse files Browse the repository at this point in the history
  • Loading branch information
Manfred Cheung authored Jun 27, 2023
1 parent 8721e53 commit b5d116b
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<template>
<Portal :appendTo="props.appendTo">
<div class="tera-context-menu" ref="container">
<Menu v-if="isVisible" :model="props.model" />
<Menu v-if="isVisible" :model="props.model">
<template v-slot:item="{ item }">
<a class="p-menuitem-link" @click="(e) => itemClick(e, item)">
<span class="p-menuitem-text">{{ item.label }}</span>
</a>
</template>
</Menu>
</div>
</Portal>
</template>
Expand Down Expand Up @@ -63,6 +69,13 @@ defineExpose({
hide
});
const itemClick = (e, item: MenuItem) => {
if (item.command) {
hide();
item.command(e);
}
};
// adapted from `position` method of primevue/contextmenu
const setPosition = () => {
const containerVal = container.value;
Expand Down

0 comments on commit b5d116b

Please sign in to comment.