From f3fd5b6584c8687c521de58a5064e8d686d0592c Mon Sep 17 00:00:00 2001 From: VdustR Date: Fri, 8 Dec 2017 09:52:34 +0800 Subject: [PATCH] fix(MdMenu): fix close-on-select props check whether clicked target is contained in menu content element within `bodyClickObserver` fix #1279 --- src/components/MdMenu/MdMenuContent.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/MdMenu/MdMenuContent.vue b/src/components/MdMenu/MdMenuContent.vue index 13c00e488..5a5f63d7b 100644 --- a/src/components/MdMenu/MdMenuContent.vue +++ b/src/components/MdMenu/MdMenuContent.vue @@ -7,7 +7,8 @@ @keydown.arrow-down.prevent="setHighlight('down')" @keydown.arrow-up.prevent="setHighlight('up')" @keydown.space.prevent="setSelection" - @keydown.enter.prevent="setSelection"> + @keydown.enter.prevent="setSelection" + ref="menu">
@@ -188,7 +189,8 @@ this.MdMenu.bodyClickObserver = new MdObserveEvent(document.body, 'click', $event => { $event.stopPropagation() let isMdMenu = this.MdMenu.$el ? this.MdMenu.$el.contains($event.target) : false - if (!this.$el.contains($event.target) && !isMdMenu) { + let isMenuContentEl = this.$refs.menu ? this.$refs.menu.contains($event.target) : false + if (!this.$el.contains($event.target) && !isMdMenu && !isMenuContentEl) { this.MdMenu.active = false this.MdMenu.bodyClickObserver.destroy() this.MdMenu.windowResizeObserver.destroy()