When attempting to utilize Vuetify's v-text-field
with the autofocus
attribute, I am facing an issue where it only works the first time. Once I close the dialog, the autofocus functionality no longer works.
This is the code snippet I am trying to implement:
<v-text-field ref="focus" autofocus></v-text-field>
While searching online, I came across a reported bug which was apparently fixed in a certain version. There was a temporary solution suggested, which I also attempted:
watch: {
dialog: (val) ->
if !val
debugger
requestAnimationFrame( =>
@$refs.focus.focus()
)
}
}
I am wondering if I am making a mistake in my implementation or if the issue still persists as a bug. When I set a breakpoint, I noticed that it stops at that particular point. Can anyone provide guidance on this matter?
The only distinction in my setup is that I am utilizing Vuex and the dialog variable is stored in the Vuex store. Furthermore, the dialog is managed through a getter/setter function.
dialog:
get: ->
return this.$store.state.my_store.isDialogOpen
set: (value) ->
this.$store.commit('my_store/MY_MUTATION', value)