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() + } } })