Skip to content

Commit

Permalink
fix(MdMenu): Close menu while another is opened (#1266)
Browse files Browse the repository at this point in the history
Remove `stopPropagation` from `MdMenu` to trigger close-menu click observer

fix #1255
  • Loading branch information
VdustR authored and marcosmoura committed Dec 6, 2017
1 parent 9073313 commit ef720c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/components/MdMenu/MdMenu.vue
Expand Up @@ -57,7 +57,8 @@
dense: this.mdDense,
closeOnSelect: this.mdCloseOnSelect,
bodyClickObserver: null,
windowResizeObserver: null
windowResizeObserver: null,
$el: this.$el
}
}
},
Expand Down Expand Up @@ -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]')
Expand Down
4 changes: 2 additions & 2 deletions src/components/MdMenu/MdMenuContent.vue
Expand Up @@ -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()
Expand Down

0 comments on commit ef720c4

Please sign in to comment.