From 8dcabc9385591f7d0c3df5cbd07e8a6ff8d016d7 Mon Sep 17 00:00:00 2001 From: konrad Date: Fri, 31 Jan 2020 16:19:04 +0000 Subject: [PATCH] Only focus inputs if the viewport is large enough (#55) Only focus inputs if the viewport is large enough Co-authored-by: kolaente Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/55 --- src/main.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.js b/src/main.js index 1c84898fc..6527d2156 100644 --- a/src/main.js +++ b/src/main.js @@ -113,9 +113,14 @@ import './registerServiceWorker' // Set focus Vue.directive('focus', { // When the bound element is inserted into the DOM... - inserted: function (el) { - // Focus the element - el.focus() + inserted: el => { + // Focus the element only if the viewport is big enough + // auto focusing elements on mobile can be annoying since in these cases the + // keyboard always pops up and takes half of the available space on the screen. + // The threshhold is the same as the breakpoints in css. + if (window.innerWidth > 769) { + el.focus() + } } })