Skip to content

Commit

Permalink
Merge pull request #6630 from KumJungMin/fix/issue-4510
Browse files Browse the repository at this point in the history
fix(TextArea): autoResize issue with v-show by implementing ResizeObserver
  • Loading branch information
tugcekucukoglu authored Nov 13, 2024
2 parents 2780f5a + 656ac72 commit aa92d01
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/primevue/src/textarea/Textarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,27 @@ export default {
extends: BaseTextarea,
inheritAttrs: false,
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();
}
},
beforeUnmount() {
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';
Expand Down

0 comments on commit aa92d01

Please sign in to comment.