File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1+ export default {
2+ beforeMount ( el , binding ) {
3+ el . clickOutsideEvent = ( event ) => {
4+ if ( ! ( el === event . target || el . contains ( event . target ) ) ) {
5+ if ( typeof binding . value === 'function' ) {
6+ binding . value ( event )
7+ }
8+ }
9+ }
10+ document . addEventListener ( 'click' , el . clickOutsideEvent )
11+ } ,
12+ unmounted ( el ) {
13+ document . removeEventListener ( 'click' , el . clickOutsideEvent )
14+ }
15+ }
Original file line number Diff line number Diff line change 11<template >
22 <div class =" vfg-select" >
3- <span class =" vfg-select-label" :class =" {'text-muted': !selectedName}" @click.prevent =" onClickInput" >
3+ <span v-on-click-outside = " () => isOpened = false " class =" vfg-select-label" :class =" {'text-muted': !selectedName}" @click.prevent =" onClickInput" >
44 <template v-if =" selectedName " >{{ selectedName }}</template >
55 <template v-else >{{ field.placeholder || 'Select an option' }}</template >
66 <span style =" float :right ;" >
3232
3333<script >
3434import { abstractField } from ' @/mixins'
35+ import onClickOutside from ' @/directives/onClickOutside.js'
3536
3637export default {
3738 name: ' FieldSelect' ,
39+ directives: { onClickOutside },
3840 mixins: [ abstractField ],
3941 data () {
4042 return {
You can’t perform that action at this time.
0 commit comments