Skip to content

Commit 6322b22

Browse files
committed
added closeOnSelect prop
1 parent d5317c2 commit 6322b22

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Multiselect.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ declare class Multiselect extends Vue {
3939
nativeSupport?: boolean;
4040
classes?: object;
4141
strict?: boolean;
42+
closeOnSelect?: boolean;
4243

4344
$emit(eventName: 'change', e: {originalEvent: Event, value: any}): this;
4445
$emit(eventName: 'select', e: {originalEvent: Event, value: any, option: any}): this;

src/composables/useOptions.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ref, toRefs, computed, watch } from 'composition-api'
1+
import { ref, toRefs, computed, watch, nextTick } from 'composition-api'
22
import normalize from './../utils/normalize'
33
import isObject from './../utils/isObject'
44
import isNullish from './../utils/isNullish'
@@ -10,7 +10,7 @@ export default function useOptions (props, context, dep)
1010
options, mode, trackBy, limit, hideSelected, createTag, label,
1111
appendNewTag, multipleLabel, object, loading, delay, resolveOnLoad,
1212
minChars, filterResults, clearOnSearch, clearOnSelect, valueProp,
13-
canDeselect, max, strict,
13+
canDeselect, max, strict, closeOnSelect,
1414
} = toRefs(props)
1515

1616
// ============ DEPENDENCIES ============
@@ -22,6 +22,7 @@ export default function useOptions (props, context, dep)
2222
const update = dep.update
2323
const pointer = dep.pointer
2424
const blur = dep.blur
25+
const deactivate = dep.deactivate
2526

2627
// ================ DATA ================
2728

@@ -244,7 +245,6 @@ export default function useOptions (props, context, dep)
244245

245246
blur()
246247
select(option)
247-
clearSearch()
248248
break
249249

250250
case 'multiple':
@@ -291,6 +291,10 @@ export default function useOptions (props, context, dep)
291291
select(option)
292292
break
293293
}
294+
295+
if (closeOnSelect.value) {
296+
deactivate()
297+
}
294298
}
295299

296300
const getOption = (val) => {

0 commit comments

Comments
 (0)