Files
deck/src/directives/focus.js
Julius Härtl e1de6d317b fix: Adapt to new nextcloud vue version
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2024-02-29 08:54:34 +01:00

23 lines
520 B
JavaScript

/**
*
* @param el
* @param binding
*/
function focusElement(el, binding) {
// If directive has bound value
if (binding.value !== undefined && !binding.value) return
// Focus the element
el.focus()
}
// Register a global custom directive called `v-focus`
export default {
bind(el, binding, vnode) {
// When the component of the element gets activated
vnode.context.$on('hook:activated', () => focusElement(el, binding))
},
// When the bound element is inserted into the DOM...
inserted: focusElement,
}