Sha256: 7f4ac7b1fb8839d08ea5e2357ecf3491cd00f71295ff3428a60839c9ff1b8881

Contents?: true

Size: 838 Bytes

Versions: 25

Compression:

Stored size: 838 Bytes

Contents

import { CocoComponent } from "@js/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

25 entries across 25 versions & 1 rubygems

Version Path
coveragebook_components-0.7.6 app/components/coco/app/elements/seamless_textarea/seamless_textarea.js
coveragebook_components-0.7.5 app/components/coco/app/elements/seamless_textarea/seamless_textarea.js
coveragebook_components-0.7.4 app/components/coco/app/elements/seamless_textarea/seamless_textarea.js
coveragebook_components-0.7.3 app/components/coco/app/elements/seamless_textarea/seamless_textarea.js
coveragebook_components-0.7.2 app/components/coco/app/elements/seamless_textarea/seamless_textarea.js