Files
jandl-taskmanager-app/app/src/plugins/tm@modal/_mixins/vuetify-fix-focus.ts
T
2024-02-06 19:20:09 +01:00

29 lines
553 B
TypeScript

export default {
// Mixin to fix autofocus on v-input in modals where date selects are used
data() {
return {
preventInputFocus: false
}
},
methods: {
setFocusEvent() {
document.querySelectorAll('.v-autocomplete input').forEach(input => {
input.addEventListener('focus', this.onInputFocus)
})
},
onDateFocus($event) {
if ($event == undefined) {
this.preventInputFocus = true
}
},
onInputFocus($event) {
if (this.preventInputFocus) {
$event.target.blur()
this.preventInputFocus = false
}
}
}
}