Commit 526a142cac0614619804477a8b73a2a0f9c834d0
1 parent
3537176f
add click outside event emitter to dropdown
Showing
1 changed file
with
5 additions
and
1 deletions
Show diff stats
src/components/dropdown/dropdown.vue
1 | <template> | 1 | <template> |
2 | <div | 2 | <div |
3 | :class="[prefixCls]" | 3 | :class="[prefixCls]" |
4 | - v-clickoutside="handleClose" | 4 | + v-clickoutside="onClickoutside" |
5 | @mouseenter="handleMouseenter" | 5 | @mouseenter="handleMouseenter" |
6 | @mouseleave="handleMouseleave"> | 6 | @mouseleave="handleMouseleave"> |
7 | <div :class="[prefixCls + '-rel']" ref="reference" @click="handleClick"><slot></slot></div> | 7 | <div :class="[prefixCls + '-rel']" ref="reference" @click="handleClick"><slot></slot></div> |
@@ -111,6 +111,10 @@ | @@ -111,6 +111,10 @@ | ||
111 | }, 150); | 111 | }, 150); |
112 | } | 112 | } |
113 | }, | 113 | }, |
114 | + onClickoutside (e) { | ||
115 | + this.handleClose(); | ||
116 | + if (this.currentVisible) this.$emit('on-clickoutside', e); | ||
117 | + }, | ||
114 | handleClose () { | 118 | handleClose () { |
115 | if (this.trigger === 'custom') return false; | 119 | if (this.trigger === 'custom') return false; |
116 | if (this.trigger !== 'click') { | 120 | if (this.trigger !== 'click') { |