Handle blank search terms
authorAdam Dullage <redacted>
Sat, 6 Aug 2022 19:06:18 +0000 (20:06 +0100)
committerAdam Dullage <redacted>
Sat, 6 Aug 2022 19:06:18 +0000 (20:06 +0100)
flatnotes/src/components/SearchInput.vue

index a02490864dfd7c1cf10ea816b09b35eeb6e664a0..06d0e907ed86a242c5f63c689751ca175822b1e4 100644 (file)
@@ -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,
+        });
+      }
     },
   },
 };
git clone https://git.99rst.org/PROJECT