Skip to content

Commit

Permalink
Fix #762 - Textarea does not auto resize its height when created
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Dec 11, 2020
1 parent 564a0d4 commit ab392b1
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/components/textarea/Textarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default {
value: null,
autoResize: Boolean
},
cachedScrollHeight: null,
mounted() {
if (this.$el.offsetParent && this.autoResize) {
this.resize();
Expand All @@ -21,24 +20,17 @@ export default {
},
methods: {
resize() {
if (!this.cachedScrollHeight) {
this.cachedScrollHeight = this.$el.scrollHeight;
this.$el.style.overflow = "hidden";
}
if (this.cachedScrollHeight !== this.$el.scrollHeight) {
this.$el.style.height = ''
this.$el.style.height = this.$el.scrollHeight + 'px';
this.$el.style.height = 'auto';
this.$el.style.height = this.$el.scrollHeight + 'px';
if (parseFloat(this.$el.style.height) >= parseFloat(this.$el.style.maxHeight)) {
this.$el.style.overflowY = "scroll";
this.$el.style.height = this.$el.style.maxHeight;
}
else {
this.$el.style.overflow = "hidden";
}
if (parseFloat(this.$el.style.height) >= parseFloat(this.$el.style.maxHeight)) {
this.$el.style.overflow = "scroll";
this.$el.style.height = this.$el.style.maxHeight;
}
this.cachedScrollHeight = this.$el.scrollHeight;
else {
this.$el.style.overflow = "hidden";
}
}
},
Expand Down

0 comments on commit ab392b1

Please sign in to comment.