diff client/src/application/Topbar.vue @ 965:ac2e51d5bc40

feat: autofocus when search expands
author Thomas Junk <thomas.junk@intevation.de>
date Wed, 17 Oct 2018 15:33:59 +0200
parents ec9c3a111bb7
children 6114c512508b
line wrap: on
line diff
--- a/client/src/application/Topbar.vue	Wed Oct 17 15:29:58 2018 +0200
+++ b/client/src/application/Topbar.vue	Wed Oct 17 15:33:59 2018 +0200
@@ -108,6 +108,8 @@
 import Identify from "../layers/Identify";
 import Layers from "../layers/Layers";
 
+const setFocus = () => document.querySelector("#search").focus();
+
 export default {
   name: "topbar",
   components: {
@@ -210,6 +212,9 @@
       this.toggleSearchbar();
     },
     toggleSearchbar() {
+      if (this.searchbarCollapsed) {
+        setTimeout(setFocus, 300);
+      }
       this.searchbarCollapsed = !this.searchbarCollapsed;
     },
     toggleSidebar() {