fix searchableInput field component to properly retrigger search on delete, clear properly etc

This commit is contained in:
Ulf Gebhardt 2023-04-25 02:19:50 +02:00
parent ca24cf4405
commit 6025706b4b
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9

View File

@ -14,9 +14,8 @@
:auto-reset-search="!searchValue"
:placeholder="$t('search.placeholder')"
@focus.capture.native="onFocus"
@input.native="handleInput"
@input.native="onInput"
@keyup.enter.native="onEnter"
@keyup.delete.native="onDelete"
@keyup.esc.native="clear"
@blur.capture.native="onBlur"
@input.exact="onSelect"
@ -103,11 +102,14 @@ export default {
onFocus(event) {
clearTimeout(this.searchProcess)
},
handleInput(event) {
onInput(event) {
console.log('input', event)
clearTimeout(this.searchProcess)
this.value = event.target ? event.target.value.replace(/\s+/g, ' ').trim() : ''
console.log('input', this.value)
this.unprocessedSearchInput = this.value
if (isEmpty(this.value) || this.value.replace(/\s+/g, '').length < 3) {
this.clear()
return
}
this.searchProcess = setTimeout(() => {
@ -122,15 +124,6 @@ export default {
})
this.$emit('clearSearch')
},
onDelete(event) {
clearTimeout(this.searchProcess)
const value = event.target ? event.target.value.trim() : ''
if (isEmpty(value)) {
this.clear()
} else {
this.handleInput(event)
}
},
clear() {
this.unprocessedSearchInput = ''
this.previousSearchTerm = ''