3
3
<!-- Tags visible to the user -->
4
4
<div class =" flex gap-2 flex-wrap items-center px-3" >
5
5
<TagsInputItem v-for =" tagValue in tags" :key =" tagValue" :value =" tagValue" >
6
- <TagsInputItemText />
6
+ <TagsInputItemText />
7
7
<TagsInputItemDelete />
8
8
</TagsInputItem >
9
9
</div >
23
23
:class =" tags.length > 0 ? 'mt-2' : ''"
24
24
@keydown.enter.prevent
25
25
@blur =" handleBlur"
26
+ @click =" open = true"
26
27
/>
27
28
</ComboboxInput >
28
29
</ComboboxAnchor >
@@ -99,11 +100,14 @@ const open = ref(false)
99
100
const searchTerm = ref (' ' )
100
101
101
102
// Get all options that are not already selected and match the search term
103
+ // If not search term is provided, return all available options
102
104
const filteredOptions = computed (() => {
103
- return props .items .filter (
104
- (item ) =>
105
- ! tags .value .includes (item .value ) &&
106
- item .label .toLowerCase ().includes (searchTerm .value .toLowerCase ())
105
+ const available = props .items .filter ((item ) => ! tags .value .includes (item .value ))
106
+
107
+ if (! searchTerm .value ) return available
108
+
109
+ return available .filter ((item ) =>
110
+ item .label .toLowerCase ().includes (searchTerm .value .toLowerCase ())
107
111
)
108
112
})
109
113
@@ -127,6 +131,8 @@ const handleSelect = (event) => {
127
131
// Custom filter function to filter items based on the search term
128
132
const filterFunc = (remainingItemValues , term ) => {
129
133
const remainingItems = props .items .filter ((item ) => remainingItemValues .includes (item .value ))
130
- return remainingItems .filter ((item ) => item .label .toLowerCase ().includes (term .toLowerCase ())).map (item => item .value )
134
+ return remainingItems
135
+ .filter ((item ) => item .label .toLowerCase ().includes (term .toLowerCase ()))
136
+ .map ((item ) => item .value )
131
137
}
132
138
< / script>
0 commit comments