diff client/src/application/Topbar.vue @ 802:327aa4a18a1c

Fairway profile WIP
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 27 Sep 2018 13:36:43 +0200
parents afe62d1ce01c
children 9b982e50e938
line wrap: on
line diff
--- a/client/src/application/Topbar.vue	Thu Sep 27 13:18:50 2018 +0200
+++ b/client/src/application/Topbar.vue	Thu Sep 27 13:36:43 2018 +0200
@@ -10,7 +10,7 @@
                 </span>
             </div>
             <div class="searchgroup">
-                <input v-if="!searchbarCollapsed" id="search" v-model="searchQuery" type="text" class="form-control ui-element search searchbar">
+                <input @keyup.enter="takeFirstSearchresult" v-if="!searchbarCollapsed" id="search" v-model="searchQuery" type="text" class="form-control ui-element search searchbar">
                 <ul v-if="!searchbarCollapsed && searchResults !== null " class="list-group">
                     <li v-for="entry of searchResults" :key="entry.name" class="list-group-item">
                         <a href="#" @click.prevent="moveToSearchResult(entry)">{{entry.name}}</a>
@@ -151,6 +151,10 @@
     }
   },
   methods: {
+    takeFirstSearchresult() {
+      if (!this.searchResults || this.searchResults.length != 1) return;
+      this.moveToSearchResult(this.searchResults[0]);
+    },
     triggerSearch: debounce(function() {
       this.doSearch();
     }, 500),