Skip to content

Commit

Permalink
fix(MdMenu): fix close-on-select props (#1280)
Browse files Browse the repository at this point in the history
check whether clicked target is contained in menu content element within `bodyClickObserver`

fix #1279
  • Loading branch information
VdustR authored and marcosmoura committed Dec 19, 2017
1 parent 1cfaf3c commit 40406af
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/MdMenu/MdMenuContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<div class="md-menu-content-container md-scrollbar" :class="$mdActiveTheme">
<md-list :class="listClasses" v-bind="$attrs" @keydown.esc="onEsc">
<slot />
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 40406af

Please sign in to comment.