Sha256: 4eb6ec7e514cacb945e4bc29d13f7b88aa0ffb084a523f041bb5ac86cfe822db

Contents?: true

Size: 852 Bytes

Versions: 7

Compression:

Stored size: 852 Bytes

Contents

import { CocoComponent } from "@assets/js/shared/coco";

export default CocoComponent("appSeamlessTextarea", () => {
  return {
    height: null,
    observer: null,
    value: null,

    options: ["multiline", "focus"],

    init() {
      this.value = this.$refs.textarea.value;
      this.$nextTick(() => {
        this.onResize();

        if (this.$options.focus) {
          this.$refs.textarea.focus();
          this.$refs.textarea.selectionStart = this.$refs.textarea.value.length;
        }
      });
    },

    onResize() {
      const textarea = this.$refs.textarea;

      if (textarea) {
        textarea.style.height = "4px";
        const newHeight = textarea.scrollHeight;
        textarea.style.height = `${newHeight}px`;

        if (this.height !== newHeight) {
          this.height = newHeight;
        }
      }
    },
  };
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
coveragebook_components-0.12.2 app/components/coco/app/elements/seamless_textarea/seamless_textarea.js
coveragebook_components-0.12.1 app/components/coco/app/elements/seamless_textarea/seamless_textarea.js
coveragebook_components-0.12.0 app/components/coco/app/elements/seamless_textarea/seamless_textarea.js
coveragebook_components-0.11.0 app/components/coco/app/elements/seamless_textarea/seamless_textarea.js
coveragebook_components-0.10.1.beta.2 app/components/coco/app/elements/seamless_textarea/seamless_textarea.js
coveragebook_components-0.10.1.beta.1 app/components/coco/app/elements/seamless_textarea/seamless_textarea.js
coveragebook_components-0.10.1.beta.0 app/components/coco/app/elements/seamless_textarea/seamless_textarea.js