Update searchTerm when initialSearchTerm is updated
authorAdam Dullage <redacted>
Fri, 17 May 2024 11:49:57 +0000 (12:49 +0100)
committerAdam Dullage <redacted>
Fri, 17 May 2024 11:49:57 +0000 (12:49 +0100)
client/partials/SearchInput.vue

index 7afac2e36af4ab6f22d6d8013ca2efc387b4df0f..c05234f4d4beeb8ded818a62dd96c183430e5f04 100644 (file)
@@ -46,7 +46,7 @@
 <script setup>
 import { mdilMagnify } from "@mdi/light-js";
 import { useToast } from "primevue/usetoast";
-import { ref } from "vue";
+import { ref, watch } from "vue";
 import { useRouter } from "vue-router";
 import * as constants from "../constants";
 
@@ -91,7 +91,7 @@ function keydownHandler(event) {
       tagChosen(tagMatches.value[tagMenuIndex.value]);
     } else if (event.key === "Escape") {
       tagMenuVisible.value = false;
-      event.stopPropagation();  // Prevent the modal from closing when the tag menu is open.
+      event.stopPropagation(); // Prevent the modal from closing when the tag menu is open.
     }
   }
   // Tag Menu Closed
@@ -192,4 +192,11 @@ function replaceWordOnCursor(replacement) {
     replacement +
     searchTerm.value.substring(end);
 }
+
+watch(
+  () => props.initialSearchTerm,
+  () => {
+    searchTerm.value = props.initialSearchTerm;
+  },
+);
 </script>
git clone https://git.99rst.org/PROJECT