Browse code

FEATWEBML-528 Fix: reset search input when selecting a folder

kladier authored on 25/11/2019 10:39:17
Showing 1 changed files
... ...
@@ -6,7 +6,7 @@
6 6
         icon="search"
7 7
         :aria-label="$t('common.search')"
8 8
         class="mail-search-form rounded-0"
9
-        @keydown.enter="search"
9
+        @keydown.enter="doSearch"
10 10
         @update="onChange"
11 11
         @reset="cancel"
12 12
     />
... ...
@@ -30,19 +30,21 @@ export default {
30 30
         };
31 31
     },
32 32
     computed: {
33
-        ...mapState("mail-webapp", ["currentFolderUid"]),
33
+        ...mapState("mail-webapp", ["currentFolderUid", "search"]),
34 34
         inputIsEmpty() {
35 35
             return this.searchedPattern === "";
36 36
         }
37 37
     },
38 38
     watch: {
39
-        currentFolderUid() {
40
-            this.searchedPattern = "";
39
+        "search.pattern": function() {
40
+            if (this.search.pattern === null) {
41
+                this.searchedPattern = "";
42
+            }
41 43
         }
42 44
     },
43 45
     methods: {
44 46
         ...mapMutations("mail-webapp", ["setSearchPattern", "setSearchLoading", "setSearchError"]),
45
-        search() {
47
+        doSearch() {
46 48
             if (this.searchedPattern != "") {
47 49
                 this.$router.push("/mail/search/" + this.searchedPattern + "/");
48 50
             }
... ...
@@ -62,7 +64,7 @@ export default {
62 64
                     clearTimeout(this.idSetTimeoutSearch);
63 65
                 }
64 66
                 this.idSetTimeoutLoading = setTimeout(this.setSearchLoading(true), MILLISECONDS_BEFORE_DISPLAY_SPINNER);
65
-                this.idSetTimeoutSearch = setTimeout(this.search, MILLISECONDS_BEFORE_TRIGGER_SEARCH);
67
+                this.idSetTimeoutSearch = setTimeout(this.doSearch, MILLISECONDS_BEFORE_TRIGGER_SEARCH);
66 68
             }
67 69
         }
68 70
     }