Skip to content

Commit

Permalink
fix(search): replace spaces with "_"
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Jun 22, 2023
1 parent b7bd233 commit 47ba721
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions components/posts/navigation/search/SearchMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,27 @@
const searchQuery = ref('')
// Change event
function onComboboxInputChange(event: InputEvent) {
let value = (event.target as HTMLInputElement).value
value = value.trim()
// Replace empty spaces with underscores
value = value.replace(/\s/g, '_')
searchQuery.value = value
}
watchDebounced(searchQuery, (value) => onSearchChange(value), { debounce: 350 })
const customTagFromQuery = computed(() => {
let tag = searchQuery.value.trim()
let tag = searchQuery.value
if (!tag || tag === '') {
return null
}
// Replace empty spaces with underscores
tag = tag.replace(/\s+/g, '_')
// If the tag is already in tagResults, return null
if (props.tagResults.some((tagResult) => tagResult.name === tag)) {
return null
Expand Down Expand Up @@ -195,9 +204,8 @@

<!-- Input -->
<ComboboxInput
:displayValue="(tag) => tag.name"
class="focus-visible:focus-util hover:hover-bg-util hover:hover-text-util w-full rounded-full border-0 bg-base-1000 px-9 py-2 text-base-content-highlight ring-1 ring-inset ring-base-0/20 sm:text-sm"
@change="searchQuery = $event.target.value"
@change="onComboboxInputChange"
/>

<!-- Button -->
Expand Down

0 comments on commit 47ba721

Please sign in to comment.