Update:Prevent MultiSelect input from adding items that are whitespace & trim whitespace before adding items

This commit is contained in:
advplyr 2024-05-26 14:37:07 -05:00
parent 7d8fb3bb10
commit 7f28fbb330
2 changed files with 19 additions and 11 deletions

View File

@ -493,9 +493,6 @@ export default {
if (match.narrator && !Array.isArray(match.narrator)) {
match.narrator = match.narrator.split(',').map((g) => g.trim())
}
if (match.author && !Array.isArray(match.author)) {
match.author = match.author.split(',').map((g) => g.trim())
}
}
console.log('Select Match', match)

View File

@ -302,6 +302,14 @@ export default {
this.recalcMenuPos()
})
},
resetInput() {
this.textInput = null
this.currentSearch = null
this.selectedMenuItemIndex = null
this.$nextTick(() => {
this.blur()
})
},
insertNewItem(item) {
this.selected.push(item)
this.$emit('input', this.selected)
@ -316,15 +324,18 @@ export default {
submitForm() {
if (!this.textInput) return
var cleaned = this.textInput.trim()
var matchesItem = this.items.find((i) => {
return i === cleaned
})
if (matchesItem) {
this.clickedOption(null, matchesItem)
const cleaned = this.textInput.trim()
if (!cleaned) {
this.resetInput()
} else {
this.insertNewItem(this.textInput)
const matchesItem = this.items.find((i) => i === cleaned)
if (matchesItem) {
this.clickedOption(null, matchesItem)
} else {
this.insertNewItem(cleaned)
}
}
if (this.$refs.input) this.$refs.input.style.width = '24px'
},
scroll() {
@ -352,4 +363,4 @@ input:read-only {
color: #aaa;
background-color: #444;
}
</style>
</style>