Skip to content

Commit 62dfdb6

Browse files
committed
displayField - additional checks
1 parent 91bb476 commit 62dfdb6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/VoerroTagsInput.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787

8888
<li v-for="(tag, index) in searchResults"
8989
:key="index"
90-
v-html="tag[displayField] || tag[textField]"
90+
v-html="getDisplayField(tag)"
9191
@mouseover="searchSelection = index"
9292
@mousedown.prevent="tagFromSearchOnClick(tag)"
9393
v-bind:class="{
@@ -864,6 +864,18 @@ export default {
864864
return JSON.stringify(tag);
865865
},
866866
867+
getDisplayField(tag) {
868+
const hasDisplayField = this.displayField !== undefined
869+
&& this.displayField !== null
870+
&& tag[this.displayField] !== undefined
871+
&& tag[this.displayField] !== null
872+
&& tag[this.displayField] !== '';
873+
874+
return hasDisplayField
875+
? tag[this.displayField]
876+
: tag[this.textField];
877+
},
878+
867879
cloneArray(arr) {
868880
return arr.map(el => Object.assign({}, el));
869881
}

0 commit comments

Comments
 (0)