mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-03-19 18:08:19 +01:00
Update:Prevent MultiSelect input from adding items that are whitespace & trim whitespace before adding items
This commit is contained in:
parent
7d8fb3bb10
commit
7f28fbb330
@ -493,9 +493,6 @@ export default {
|
|||||||
if (match.narrator && !Array.isArray(match.narrator)) {
|
if (match.narrator && !Array.isArray(match.narrator)) {
|
||||||
match.narrator = match.narrator.split(',').map((g) => g.trim())
|
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)
|
console.log('Select Match', match)
|
||||||
|
@ -302,6 +302,14 @@ export default {
|
|||||||
this.recalcMenuPos()
|
this.recalcMenuPos()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
resetInput() {
|
||||||
|
this.textInput = null
|
||||||
|
this.currentSearch = null
|
||||||
|
this.selectedMenuItemIndex = null
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.blur()
|
||||||
|
})
|
||||||
|
},
|
||||||
insertNewItem(item) {
|
insertNewItem(item) {
|
||||||
this.selected.push(item)
|
this.selected.push(item)
|
||||||
this.$emit('input', this.selected)
|
this.$emit('input', this.selected)
|
||||||
@ -316,15 +324,18 @@ export default {
|
|||||||
submitForm() {
|
submitForm() {
|
||||||
if (!this.textInput) return
|
if (!this.textInput) return
|
||||||
|
|
||||||
var cleaned = this.textInput.trim()
|
const cleaned = this.textInput.trim()
|
||||||
var matchesItem = this.items.find((i) => {
|
if (!cleaned) {
|
||||||
return i === cleaned
|
this.resetInput()
|
||||||
})
|
|
||||||
if (matchesItem) {
|
|
||||||
this.clickedOption(null, matchesItem)
|
|
||||||
} else {
|
} 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'
|
if (this.$refs.input) this.$refs.input.style.width = '24px'
|
||||||
},
|
},
|
||||||
scroll() {
|
scroll() {
|
||||||
@ -352,4 +363,4 @@ input:read-only {
|
|||||||
color: #aaa;
|
color: #aaa;
|
||||||
background-color: #444;
|
background-color: #444;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user