Sha256: 55040cb37d15535be582f0b6aba6e9ff279cd1ab1607be0c5a9c26f1082ded1f

Contents?: true

Size: 852 Bytes

Versions: 22

Compression:

Stored size: 852 Bytes

Contents

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

export default CocoComponent("seamlessTextarea", () => {
  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

22 entries across 22 versions & 1 rubygems

Version Path
coveragebook_components-0.19.8 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.19.7 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.19.6 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.19.5 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.19.4 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.19.3 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.19.2 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.19.1 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.19.0 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.18.8 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.18.7 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.18.0 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.17.7 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.17.6 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.17.5 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.17.4 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.17.3 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.17.2 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.17.1 app/components/coco/utilities/seamless_textarea/seamless_textarea.js
coveragebook_components-0.17.0 app/components/coco/utilities/seamless_textarea/seamless_textarea.js