Commit 9c1b5c1c324a95c64b3c80da62f42d1f077cae05
Committed by
GitHub

Merge pull request #2783 from SergioCrisostomo/add-clickoutside-event
New feature: add "clickoutside" 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') { |