vue-formulate icon indicating copy to clipboard operation
vue-formulate copied to clipboard

textarea

Open onno-timmerman opened this issue 3 years ago • 1 comments

It would be nice to have an option to make textarea auto grow when you type into it.

onno-timmerman avatar Mar 17 '21 15:03 onno-timmerman

a simple sullution:

<template>
                <FormulateInput
                    type="textarea"
                    name="abstract"
                    input-class="resize-none"
                    ref="autoTextAreaHeight"
                    @input="autoTextAreaHeight"
                />
</template>
<script>

export default {

  mounted() {
      this.autoTextAreaHeight();
  },

methods:{
    autoTextAreaHeight() {

      if (!this.$refs.autoTextAreaHeight) return;

      var ele = this.$refs.autoTextAreaHeight.$el.querySelector("textarea");
      ele.style.height = 'auto'
      ele.style.height = (ele.scrollHeight) + 'px'
    },

 }
}
</script>

<style>

// tailwind css has already shiped with this class
.resize-none{
  resize:none
}

</style>

scil avatar Aug 30 '22 22:08 scil