better approach

This commit is contained in:
Henry Jameson 2018-04-15 19:05:16 +03:00
parent 600b2d5bbd
commit e1dce2c5af
2 changed files with 10 additions and 5 deletions

View file

@ -28,6 +28,10 @@ const PostStatusForm = {
components: {
MediaUpload
},
mounted () {
console.log(this.$refs)
this.resize(this.$refs.textarea)
},
data () {
let statusText = ''
@ -235,10 +239,11 @@ const PostStatusForm = {
e.dataTransfer.dropEffect = 'copy'
},
resize (e) {
e.target.style.height = 'auto'
e.target.style.height = `${e.target.scrollHeight - 10}px`
if (e.target.value === '') {
e.target.style.height = '16px'
const target = e.target || e
target.style.height = 'auto'
target.style.height = `${target.scrollHeight - 10}px`
if (target.value === '') {
target.style.height = '16px'
}
},
clearError () {

View file

@ -3,6 +3,7 @@
<form @submit.prevent="postStatus(newStatus)">
<div class="form-group" >
<textarea
ref="textarea"
@click="setCaret"
@keyup="setCaret" v-model="newStatus.status" :placeholder="$t('post_status.default')" rows="1" class="form-control"
@keydown.down="cycleForward"
@ -15,7 +16,6 @@
@drop="fileDrop"
@dragover.prevent="fileDrag"
@input="resize"
@focus="resize"
@paste="paste">
</textarea>
</div>