[UI] Fixed Autocomplete behaviour on empty filter.

This commit is contained in:
Fabio Manganiello 2023-10-16 01:12:56 +02:00
parent c88a9da3e6
commit 0055acad9d
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -25,8 +25,8 @@
v-for="(item, i) in visibleItems" v-for="(item, i) in visibleItems"
@click="onItemSelect(item)" @click="onItemSelect(item)"
> >
<span class="matching">{{ item.substr(0, value.length) }}</span> <span class="matching" v-if="value?.length">{{ item.substr(0, value.length) }}</span>
<span class="normal">{{ item.substr(value.length) }}</span> <span class="normal">{{ item.substr(value?.length || 0) }}</span>
</div> </div>
</div> </div>
</div> </div>
@ -80,6 +80,9 @@ export default {
computed: { computed: {
visibleItems() { visibleItems() {
if (!this.value?.length)
return this.items
const val = this.value.toUpperCase() const val = this.value.toUpperCase()
if (!val?.length) if (!val?.length)
return this.showResultsWhenBlank ? this.items : [] return this.showResultsWhenBlank ? this.items : []
@ -125,6 +128,9 @@ export default {
}, },
valueIsInItems() { valueIsInItems() {
if (!this.value)
return false
return this.items.indexOf(this.value) >= 0 return this.items.indexOf(this.value) >= 0
}, },