diff options
| author | HJ <spam@hjkos.com> | 2018-12-25 01:29:18 +0000 |
|---|---|---|
| committer | HJ <spam@hjkos.com> | 2018-12-25 01:29:18 +0000 |
| commit | 698328dfbe81a0038e05810c54118ec40c7b09ce (patch) | |
| tree | 87ecbc29b6e994aa1a7175bd6e55e78cf2400df3 | |
| parent | e59b67e119f1f598354fb0dca86774e1b0f6c4c4 (diff) | |
| parent | 18d7684f3243da4068dcc21b66854484fb61b062 (diff) | |
Merge branch 'fix_textfields' into 'develop'
Fix textarea not resizing correctly and probably cursor position
Closes #230
See merge request pleroma/pleroma-fe!430
| -rw-r--r-- | src/components/post_status_form/post_status_form.js | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 89091f8e..8a4e2489 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -32,6 +32,8 @@ const PostStatusForm = { }, mounted () { this.resize(this.$refs.textarea) + const textLength = this.$refs.textarea.value.length + this.$refs.textarea.setSelectionRange(textLength, textLength) if (this.replyTo) { this.$refs.textarea.focus() @@ -250,7 +252,8 @@ const PostStatusForm = { } this.$emit('posted') let el = this.$el.querySelector('textarea') - el.style.height = '16px' + el.style.height = 'auto' + el.style.height = undefined this.error = null } else { this.error = data.error @@ -298,13 +301,15 @@ const PostStatusForm = { e.dataTransfer.dropEffect = 'copy' }, resize (e) { - if (!e.target) { return } - const vertPadding = Number(window.getComputedStyle(e.target)['padding-top'].substr(0, 1)) + - Number(window.getComputedStyle(e.target)['padding-bottom'].substr(0, 1)) - e.target.style.height = 'auto' - e.target.style.height = `${e.target.scrollHeight - vertPadding}px` - if (e.target.value === '') { - e.target.style.height = '16px' + const target = e.target || e + if (!(target instanceof window.Element)) { return } + const vertPadding = Number(window.getComputedStyle(target)['padding-top'].substr(0, 1)) + + Number(window.getComputedStyle(target)['padding-bottom'].substr(0, 1)) + // Auto is needed to make textbox shrink when removing lines + target.style.height = 'auto' + target.style.height = `${target.scrollHeight - vertPadding}px` + if (target.value === '') { + target.style.height = null } }, clearError () { |
