vikunja-frontend/src/directives/focus.ts

13 lines
461 B
TypeScript
Raw Normal View History

2020-11-02 21:52:07 +01:00
export default {
// When the bound element is inserted into the DOM...
mounted: (el, {modifiers}) => {
2020-11-02 21:52:07 +01:00
// 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.
2021-12-10 13:21:25 +01:00
if (window.innerWidth > 769 || modifiers?.always) {
2020-11-02 21:52:07 +01:00
el.focus()
}
},
}