Skip to content

Commit ef720c4

Browse files
VdustRmarcosmoura
authored andcommitted
fix(MdMenu): Close menu while another is opened (#1266)
Remove `stopPropagation` from `MdMenu` to trigger close-menu click observer fix #1255
1 parent 9073313 commit ef720c4

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/components/MdMenu/MdMenu.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
dense: this.mdDense,
5858
closeOnSelect: this.mdCloseOnSelect,
5959
bodyClickObserver: null,
60-
windowResizeObserver: null
60+
windowResizeObserver: null,
61+
$el: this.$el
6162
}
6263
}
6364
},
@@ -105,11 +106,11 @@
105106
},
106107
methods: {
107108
toggleContent ($event) {
108-
$event.stopPropagation()
109109
this.MdMenu.active = !this.MdMenu.active
110110
}
111111
},
112112
async mounted () {
113+
this.MdMenu.$el = this.$el
113114
await this.$nextTick()
114115
115116
this.triggerEl = this.$el.querySelector('[md-menu-trigger]')

src/components/MdMenu/MdMenuContent.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@
187187
if (document) {
188188
this.MdMenu.bodyClickObserver = new MdObserveEvent(document.body, 'click', $event => {
189189
$event.stopPropagation()
190-
191-
if (!this.$el.contains($event.target)) {
190+
let isMdMenu = this.MdMenu.$el ? this.MdMenu.$el.contains($event.target) : false
191+
if (!this.$el.contains($event.target) && !isMdMenu) {
192192
this.MdMenu.active = false
193193
this.MdMenu.bodyClickObserver.destroy()
194194
this.MdMenu.windowResizeObserver.destroy()

0 commit comments

Comments
 (0)