diff --git a/src/components/MdMenu/MdMenu.vue b/src/components/MdMenu/MdMenu.vue index 7dd55b53f..2fff86ea9 100644 --- a/src/components/MdMenu/MdMenu.vue +++ b/src/components/MdMenu/MdMenu.vue @@ -57,7 +57,8 @@ dense: this.mdDense, closeOnSelect: this.mdCloseOnSelect, bodyClickObserver: null, - windowResizeObserver: null + windowResizeObserver: null, + $el: this.$el } } }, @@ -105,11 +106,11 @@ }, methods: { toggleContent ($event) { - $event.stopPropagation() this.MdMenu.active = !this.MdMenu.active } }, async mounted () { + this.MdMenu.$el = this.$el await this.$nextTick() this.triggerEl = this.$el.querySelector('[md-menu-trigger]') diff --git a/src/components/MdMenu/MdMenuContent.vue b/src/components/MdMenu/MdMenuContent.vue index 4e9569527..13c00e488 100644 --- a/src/components/MdMenu/MdMenuContent.vue +++ b/src/components/MdMenu/MdMenuContent.vue @@ -187,8 +187,8 @@ if (document) { this.MdMenu.bodyClickObserver = new MdObserveEvent(document.body, 'click', $event => { $event.stopPropagation() - - if (!this.$el.contains($event.target)) { + let isMdMenu = this.MdMenu.$el ? this.MdMenu.$el.contains($event.target) : false + if (!this.$el.contains($event.target) && !isMdMenu) { this.MdMenu.active = false this.MdMenu.bodyClickObserver.destroy() this.MdMenu.windowResizeObserver.destroy()