mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
Improve search form submission logic (#107)
Refactor search logic to trim input and auto-append region if necessary. Standardize URL format for search queries.
This commit is contained in:
parent
c36bdcba2b
commit
44978549ed
1 changed files with 20 additions and 5 deletions
|
|
@ -102,7 +102,6 @@ export default {
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
open(newVal) {
|
open(newVal) {
|
||||||
// Search Dropdown open
|
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
this.dropDownOpening()
|
this.dropDownOpening()
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -147,17 +146,33 @@ export default {
|
||||||
}
|
}
|
||||||
document.body.style.overflow = 'hidden'
|
document.body.style.overflow = 'hidden'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// UPDATED SEARCH LOGIC
|
||||||
formSubmit() {
|
formSubmit() {
|
||||||
const search = this.summoner.split(' ').join('').replaceAll('+', ' ').replaceAll('#', '-')
|
let query = this.summoner.trim()
|
||||||
if (search.length) {
|
|
||||||
|
if (query.length) {
|
||||||
|
// If the user didn't include a tagline (# or -), auto-append the region
|
||||||
|
if (!query.includes('#') && !query.includes('-')) {
|
||||||
|
query = `${query}-${this.selectedRegion.toUpperCase()}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Standardize the URL format (project uses '-' instead of '#')
|
||||||
|
const search = query
|
||||||
|
.split(' ')
|
||||||
|
.join('')
|
||||||
|
.replaceAll('+', ' ')
|
||||||
|
.replaceAll('#', '-')
|
||||||
|
|
||||||
this.$emit('formSubmit', search, this.selectedRegion)
|
this.$emit('formSubmit', search, this.selectedRegion)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getScrollbarWidth() {
|
getScrollbarWidth() {
|
||||||
const outer = document.createElement('div')
|
const outer = document.createElement('div')
|
||||||
outer.style.visibility = 'hidden'
|
outer.style.visibility = 'hidden'
|
||||||
outer.style.overflow = 'scroll' // forcing scrollbar to appear
|
outer.style.overflow = 'scroll'
|
||||||
outer.style.msOverflowStyle = 'scrollbar' // needed for WinJS apps
|
outer.style.msOverflowStyle = 'scrollbar'
|
||||||
document.body.appendChild(outer)
|
document.body.appendChild(outer)
|
||||||
|
|
||||||
const inner = document.createElement('div')
|
const inner = document.createElement('div')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue