File tree Expand file tree Collapse file tree 2 files changed +33
-6
lines changed Expand file tree Collapse file tree 2 files changed +33
-6
lines changed Original file line number Diff line number Diff line change 44
44
return MdListItemExpand
45
45
}
46
46
47
+ if (props .disabled ) {
48
+ return MdListItemButton
49
+ }
50
+
47
51
if (isRouterLink (parent, props)) {
48
52
MdListItemRouter .props = MdRouterLinkProps (parent, {
49
53
target: String
Original file line number Diff line number Diff line change 26
26
}
27
27
}
28
28
},
29
+ methods: {
30
+ closeMenu () {
31
+ this .MdMenu .active = false
32
+
33
+ if (this .MdMenu .eventObserver ) {
34
+ this .MdMenu .eventObserver .destroy ()
35
+ }
36
+ },
37
+
38
+ triggerCloseMenu () {
39
+ if (! this .disabled ) {
40
+ this .closeMenu ()
41
+ }
42
+ }
43
+ },
29
44
created () {
30
45
if (this .MdMenu .closeOnSelect ) {
31
46
let listenerNames = Object .keys (this .$listeners )
32
- let hasInteraction = false
33
47
34
48
listenerNames .forEach (listener => {
35
49
if (MdInteractionEvents .includes (listener)) {
36
50
this .listeners [listener] = $event => {
37
51
if (! this .disabled ) {
38
52
this .$listeners [listener]($event)
39
- this .MdMenu .active = false
40
-
41
- if (this .MdMenu .eventObserver ) {
42
- this .MdMenu .eventObserver .destroy ()
43
- }
53
+ this .closeMenu ()
44
54
}
45
55
}
46
56
} else {
50
60
} else {
51
61
this .listeners = this .$listeners
52
62
}
63
+ },
64
+ mounted () {
65
+ if (this .$el .children && this .$el .children [0 ]) {
66
+ let listItem = this .$el .children [0 ]
67
+
68
+ if (listItem .tagName .toUpperCase () === ' A' ) {
69
+ this .$el .addEventListener (' click' , this .triggerCloseMenu )
70
+ }
71
+ }
72
+ },
73
+
74
+ beforeDestroy () {
75
+ this .$el .removeEventListener (' click' , this .triggerCloseMenu )
53
76
}
54
77
})
55
78
</script >
You can’t perform that action at this time.
0 commit comments