[Teams] Autocomplete input component

This commit is contained in:
Matej Glasnák committed 2022-11-29 20:28:34 +01:00
1 parent da9d338175
commit e881020f86
1 file changed
+6 -3
@@ -7,7 +7,7 @@
@keydown.enter="optionSelected()" @keydown.enter="optionSelected()"
/> />
<div class="suggestion"> <div class="suggestion" v-if="suggestion">
<span class="hidden-part">{{ suggestion._suggestionHiddenPart }}</span> <span class="hidden-part">{{ suggestion._suggestionHiddenPart }}</span>
<span>{{ suggestion._suggestionShownPart }}</span> <span>{{ suggestion._suggestionShownPart }}</span>
</div> </div>
@@ -36,7 +36,7 @@ export default {
const normalizedSearch = this._normalize(this.search) const normalizedSearch = this._normalize(this.search)
if (!normalizedSearch.length || !this.options.length) if (!normalizedSearch.length || !this.options.length)
return '' return null
const filteredOptions = this.options.filter(option => { const filteredOptions = this.options.filter(option => {
const normalizedValue = this._normalize(option.value) const normalizedValue = this._normalize(option.value)
@@ -45,7 +45,7 @@ export default {
}) })
if (!filteredOptions[0]) if (!filteredOptions[0])
return '' return null
const suggestion = { const suggestion = {
...filteredOptions[0], ...filteredOptions[0],
@@ -60,6 +60,9 @@ export default {
methods: { methods: {
optionSelected() { optionSelected() {
if (!this.suggestion)
return
this.$emit('option-selected', this.suggestion) this.$emit('option-selected', this.suggestion)
this.search = '' this.search = ''
}, },