mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 04:47:27 +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: {
|
||||
open(newVal) {
|
||||
// Search Dropdown open
|
||||
if (newVal) {
|
||||
this.dropDownOpening()
|
||||
} else {
|
||||
|
|
@ -147,17 +146,33 @@ export default {
|
|||
}
|
||||
document.body.style.overflow = 'hidden'
|
||||
},
|
||||
|
||||
// UPDATED SEARCH LOGIC
|
||||
formSubmit() {
|
||||
const search = this.summoner.split(' ').join('').replaceAll('+', ' ').replaceAll('#', '-')
|
||||
if (search.length) {
|
||||
let query = this.summoner.trim()
|
||||
|
||||
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)
|
||||
}
|
||||
},
|
||||
|
||||
getScrollbarWidth() {
|
||||
const outer = document.createElement('div')
|
||||
outer.style.visibility = 'hidden'
|
||||
outer.style.overflow = 'scroll' // forcing scrollbar to appear
|
||||
outer.style.msOverflowStyle = 'scrollbar' // needed for WinJS apps
|
||||
outer.style.overflow = 'scroll'
|
||||
outer.style.msOverflowStyle = 'scrollbar'
|
||||
document.body.appendChild(outer)
|
||||
|
||||
const inner = document.createElement('div')
|
||||
|
|
|
|||
Loading…
Reference in a new issue