From: Adam Dullage Date: Sat, 6 Aug 2022 19:06:18 +0000 (+0100) Subject: Handle blank search terms X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=63260ae9415305b0625f57c95c03dd6d71a8adea;p=flatnotes.git Handle blank search terms --- diff --git a/flatnotes/src/components/SearchInput.vue b/flatnotes/src/components/SearchInput.vue index a024908..06d0e90 100644 --- a/flatnotes/src/components/SearchInput.vue +++ b/flatnotes/src/components/SearchInput.vue @@ -44,12 +44,22 @@ export default { methods: { search: function () { - EventBus.$emit( - "navigate", - `/${constants.basePaths.search}?${ - constants.params.searchTerm - }=${encodeURI(this.searchTermInput)}` - ); + if (this.searchTermInput) { + this.searchTermInput = this.searchTermInput.trim(); + } + if (this.searchTermInput) { + EventBus.$emit( + "navigate", + `/${constants.basePaths.search}?${ + constants.params.searchTerm + }=${encodeURI(this.searchTermInput)}` + ); + } else { + this.$bvToast.toast("Please enter a search term ✘", { + variant: "danger", + noCloseButton: true, + }); + } }, }, };