diff --git a/contentcuration/contentcuration/frontend/shared/views/ContextMenuCloak.vue b/contentcuration/contentcuration/frontend/shared/views/ContextMenuCloak.vue index f8f3e951b2..637fee0529 100644 --- a/contentcuration/contentcuration/frontend/shared/views/ContextMenuCloak.vue +++ b/contentcuration/contentcuration/frontend/shared/views/ContextMenuCloak.vue @@ -28,6 +28,12 @@ return !this.disabled && this.currentContextMenu === this._uid; }, }, + mounted() { + document.addEventListener('click', this.hideMenu); + }, + beforeDestroy() { + document.removeEventListener('click', this.hideMenu); + }, methods: { ...mapMutations('contextMenu', { setMenu: 'SET_CONTEXT_MENU' }), showMenu(e) { @@ -37,8 +43,14 @@ this.y = e.clientY; this.setMenu(this._uid); }, + hideMenu(e) { + if (this.currentContextMenu && !this.$el.contains(e.target)) { + this.setMenu(''); + } + }, extendSlot, }, + render() { if (this.disabled) { return this.extendSlot('default');