Only focus inputs if the viewport is large enough (#55)
continuous-integration/drone/push Build is passing Details

Only focus inputs if the viewport is large enough

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: #55
This commit is contained in:
konrad 2020-01-31 16:19:04 +00:00
parent 96fddd9bbd
commit 8dcabc9385
1 changed files with 8 additions and 3 deletions

View File

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