From 49b245863451736cee7d8884db02fd6e1fdd24a4 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 4 Jan 2026 03:37:27 +0000 Subject: [PATCH] Improve search form submission logic Refactor search logic to trim input and auto-append region if necessary. Standardize URL format for search queries. --- client/src/components/Form/SearchForm.vue | 25 ++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/client/src/components/Form/SearchForm.vue b/client/src/components/Form/SearchForm.vue index e46105b..189cf1c 100644 --- a/client/src/components/Form/SearchForm.vue +++ b/client/src/components/Form/SearchForm.vue @@ -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')