fix: Set focus in watch directive on newToot

This commit is contained in:
AkiraFukushima 2018-04-10 23:13:43 +09:00
parent 86951ecce2
commit 602c8e349d
1 changed files with 8 additions and 4 deletions

View File

@ -6,7 +6,7 @@
class="new-toot-modal">
<el-form v-on:submit.prevent="toot">
<div class="status">
<textarea v-model="status" ref="status" v-shortkey="{linux: ['ctrl', 'enter'], mac: ['meta', 'enter']}" @shortkey="toot()"></textarea>
<textarea v-model="status" ref="status" v-shortkey="{linux: ['ctrl', 'enter'], mac: ['meta', 'enter']}" @shortkey="toot()" autofocus></textarea>
</div>
</el-form>
<div class="preview">
@ -67,9 +67,13 @@ export default {
}
}
},
updated () {
if (this.newTootModal) {
this.$refs.status.focus()
watch: {
newTootModal: function (newState, oldState) {
if (!oldState && newState) {
this.$nextTick(function () {
this.$refs.status.focus()
})
}
}
},
methods: {