Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Do not submit if the input value is blank
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed Nov 10, 2022
1 parent 7e1b2a5 commit 288a8e8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/VHeader/VSearchBar/VStandaloneSearchBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ export default defineComponent({
setup(props, { emit }) {
const inputRef = ref<HTMLInputElement | null>(null)
// Only emit `submit` if the input value is not blank
const handleSearch = () => {
const searchTerm = inputRef.value?.value.trim() || ''
emit('submit', searchTerm)
const searchTerm = inputRef.value?.value.trim()
if (searchTerm) {
emit('submit', searchTerm)
}
}
const isHomeRoute = computed(() => props.route === 'home')
Expand Down

0 comments on commit 288a8e8

Please sign in to comment.