fix: Adapt to new nextcloud vue version
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
22
src/directives/focus.js
Normal file
22
src/directives/focus.js
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
*
|
||||
* @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,
|
||||
}
|
||||
Reference in New Issue
Block a user