correctly resize text input after posting

This commit is contained in:
Nolan Lawson 2018-03-19 20:58:53 -07:00
parent 5f670f6eb3
commit 1786d737bb
1 changed files with 17 additions and 4 deletions

View File

@ -41,10 +41,19 @@
}, },
methods: { methods: {
setupSyncFromStore() { setupSyncFromStore() {
let textarea = this.refs.textarea
let firstTime = true
this.observe('text', text => { this.observe('text', text => {
this.set({rawText: text}) this.set({rawText: text})
if (firstTime) {
firstTime = false
if (this.get('autoFocus')) { if (this.get('autoFocus')) {
this.refs.textarea.focus() textarea.focus()
}
} else {
mark('autosize.update()')
autosize.update(textarea)
stop('autosize.update()')
} }
}) })
}, },
@ -60,9 +69,10 @@
}, {init: false}) }, {init: false})
}, },
setupAutosize() { setupAutosize() {
let textarea = this.refs.textarea
requestAnimationFrame(() => { requestAnimationFrame(() => {
mark('autosize()') mark('autosize()')
autosize(this.refs.textarea) autosize(textarea)
stop('autosize()') stop('autosize()')
}) })
}, },
@ -78,6 +88,9 @@
store: () => store, store: () => store,
data: () => ({ data: () => ({
rawText: '' rawText: ''
}) }),
computed: {
postedStatusForRealm: ($postedStatusForRealm) => $postedStatusForRealm
}
} }
</script> </script>