diff --git a/packages/primevue/src/textarea/Textarea.vue b/packages/primevue/src/textarea/Textarea.vue index 2419176a9f..c29fe0262a 100755 --- a/packages/primevue/src/textarea/Textarea.vue +++ b/packages/primevue/src/textarea/Textarea.vue @@ -15,17 +15,27 @@ export default { $pcFluid: { default: null } }, mounted() { - if (this.$el.offsetParent && this.autoResize) { - this.resize(); + if (this.autoResize) { + this.observer = new ResizeObserver(() => { + this.resize(); + }); + this.observer.observe(this.$el); } }, updated() { - if (this.$el.offsetParent && this.autoResize) { + if (this.autoResize) { this.resize(); } }, + onBeforeUnmount() { + if (this.observer) { + this.observer.disconnect(); + } + }, methods: { resize() { + if (!this.$el.offsetParent) return; + this.$el.style.height = 'auto'; this.$el.style.height = this.$el.scrollHeight + 'px';