Improve global menu search behavior for multiple terms
This commit is contained in:
parent
6ab3898f27
commit
18f8577005
|
@ -757,8 +757,27 @@
|
||||||
if (!this.globalSearchTerm.length) {
|
if (!this.globalSearchTerm.length) {
|
||||||
return this.globalSearchData
|
return this.globalSearchData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let terms = []
|
||||||
|
for (let term of this.globalSearchTerm.toLowerCase().split(' ')) {
|
||||||
|
term = term.trim()
|
||||||
|
if (term) {
|
||||||
|
terms.push(term)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!terms.length) {
|
||||||
|
return this.globalSearchData
|
||||||
|
}
|
||||||
|
|
||||||
|
// all terms must match
|
||||||
return this.globalSearchData.filter((option) => {
|
return this.globalSearchData.filter((option) => {
|
||||||
return option.label.toLowerCase().indexOf(this.globalSearchTerm.toLowerCase()) >= 0
|
let label = option.label.toLowerCase()
|
||||||
|
for (let term of terms) {
|
||||||
|
if (label.indexOf(term) < 0) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue