Skip to content

Commit 5869079

Browse files
authored
Merge pull request sagalbot#421 from MarZab/issue-350
The temporary option when using taggable should be a Object
2 parents 860e439 + 592df53 commit 5869079

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

dev.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@
4747
{{option.label}} ({{option.value}})
4848
</template>
4949
</v-select>
50+
<v-select placeholder="custom option template for string array" taggable :options="['cat', 'dog', 'bear']" multiple>
51+
<template slot="selected-option" slot-scope="option">
52+
{{option.label}}
53+
</template>
54+
<template slot="option" slot-scope="option">
55+
{{option.label}}
56+
</template>
57+
</v-select>
5058
<v-select multiple placeholder="custom label template" :options="options">
5159
<span
5260
slot="selected-option-container"

src/components/Select.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@
313313
<div ref="toggle" @mousedown.prevent="toggleDropdown" :class="['dropdown-toggle', 'clearfix']">
314314

315315
<slot v-for="option in valueAsArray" name="selected-option-container"
316-
:option="option" :deselect="deselect" :multiple="multiple" :disabled="disabled">
316+
:option="(typeof option === 'object')?option:{[label]: option}" :deselect="deselect" :multiple="multiple" :disabled="disabled">
317317
<span class="selected-tag" v-bind:key="option.index">
318-
<slot name="selected-option" v-bind="option">
318+
<slot name="selected-option" v-bind="(typeof option === 'object')?option:{[label]: option}">
319319
{{ getOptionLabel(option) }}
320320
</slot>
321321
<button v-if="multiple" :disabled="disabled" @click="deselect(option)" type="button" class="close" aria-label="Remove option">
@@ -368,7 +368,7 @@
368368
<ul ref="dropdownMenu" v-if="dropdownOpen" class="dropdown-menu" :style="{ 'max-height': maxHeight }">
369369
<li v-for="(option, index) in filteredOptions" v-bind:key="index" :class="{ active: isOptionSelected(option), highlight: index === typeAheadPointer }" @mouseover="typeAheadPointer = index">
370370
<a @mousedown.prevent="select(option)">
371-
<slot name="option" v-bind="option">
371+
<slot name="option" v-bind="(typeof option === 'object')?option:{[label]: option}">
372372
{{ getOptionLabel(option) }}
373373
</slot>
374374
</a>

0 commit comments

Comments
 (0)