Skip to content

Commit dc7d497

Browse files
committed
fix Autocomplete options when it's a string[]
1 parent f7aca53 commit dc7d497

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/components/Autocomplete.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
:class="[option === active ? 'active bg-indigo-600 text-white' : 'text-gray-900 dark:text-gray-100', 'relative cursor-default select-none py-2 pl-3 pr-9']"
3030
@mouseover="setActive(option)" @click="select(option)" role="option" tabindex="-1">
3131

32-
<slot name="item" v-bind="option"></slot>
32+
<slot v-if="typeof option === 'string'" name="item" v-bind="{ key:option, value:option }"></slot>
33+
<slot v-else name="item" v-bind="option"></slot>
3334

3435
<span v-if="hasOption(option)" :class="['absolute inset-y-0 right-0 flex items-center pr-4', option === active ? 'text-white' : 'text-indigo-600']">
3536
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
@@ -39,7 +40,8 @@
3940
</li>
4041
</ul>
4142
<div v-else-if="!multiple && modelValue" @keydown="keyDown" @click="toggle(!expanded)" class="h-8 -mt-8 ml-3 pt-0.5">
42-
<slot name="item" v-bind="modelValue"></slot>
43+
<slot v-if="typeof modelValue === 'string'" name="item" v-bind="{ key:modelValue, value:modelValue }"></slot>
44+
<slot v-else name="item" v-bind="modelValue"></slot>
4345
</div>
4446

4547
<div v-if="errorField" class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none" tabindex="-1">

0 commit comments

Comments
 (0)