diff --git a/web/app/components/custom-editable-field.hbs b/web/app/components/custom-editable-field.hbs index 04f966795..4e98eccc0 100644 --- a/web/app/components/custom-editable-field.hbs +++ b/web/app/components/custom-editable-field.hbs @@ -25,6 +25,7 @@ diff --git a/web/app/components/document/sidebar.hbs b/web/app/components/document/sidebar.hbs index 7191ab257..0f2fd2c5f 100644 --- a/web/app/components/document/sidebar.hbs +++ b/web/app/components/document/sidebar.hbs @@ -101,7 +101,9 @@ <:editing as |F|> <:editing as |F|> { + instance.updateHeight(); + }); + + instance.element = null; + } +} + +export default class AutoHeightTextareaModifier extends Modifier { + element: HTMLTextAreaElement | null = null; + + modify(element: HTMLTextAreaElement) { + this.element = element; + + this.element.setAttribute("rows", "1"); + this.element.style.resize = "none"; + this.element.style.overflow = "hidden"; + + // set initial height + this.updateHeight(); + + this.element.addEventListener("input", () => { + this.updateHeight(); + }); + + registerDestructor(this, cleanup); + } + + updateHeight() { + const { element } = this; + assert("element must exist", element); + + // measure any strokes + const offset = element.offsetHeight - element.clientHeight; + + // temporarily set the textarea's height to 0 to force a scrollHeight + element.style.height = "0"; + + // set the height to the scrollHeight + offset + element.style.height = element.scrollHeight + offset + "px"; + } +} diff --git a/web/app/styles/components/sidebar.scss b/web/app/styles/components/sidebar.scss index 14941b8ec..7f84fcc30 100644 --- a/web/app/styles/components/sidebar.scss +++ b/web/app/styles/components/sidebar.scss @@ -1,7 +1,8 @@ .sidebar { @apply flex flex-col max-h-full relative z-10; - header, nav { + header, + nav { @apply sticky top-0 mb-4; } @@ -11,6 +12,10 @@ height: 100%; } + .primary-textarea { + @apply min-h-[76px]; + } + .person-list { @apply w-full list-none space-y-2; } diff --git a/web/app/templates/authenticated/dashboard.hbs b/web/app/templates/authenticated/dashboard.hbs index 8de3dffdd..bbe389e07 100644 --- a/web/app/templates/authenticated/dashboard.hbs +++ b/web/app/templates/authenticated/dashboard.hbs @@ -7,7 +7,6 @@

Welcome back, {{this.authenticatedUser.info.given_name}}

Here’s all the latest updates across the organization.

-
{{#if this.docsWaitingForReview}} diff --git a/web/package.json b/web/package.json index 6c6602b5a..c5c622304 100644 --- a/web/package.json +++ b/web/package.json @@ -82,7 +82,7 @@ "ember-focus-trap": "^1.0.1", "ember-load-initializers": "^2.1.2", "ember-maybe-import-regenerator": "^0.1.6", - "ember-modifier": "^4.0.0", + "ember-modifier": "^4.1.0", "ember-on-helper": "^0.1.0", "ember-page-title": "^6.2.2", "ember-qunit": "^5.1.5", diff --git a/web/tests/integration/modifiers/auto-height-textarea-test.ts b/web/tests/integration/modifiers/auto-height-textarea-test.ts new file mode 100644 index 000000000..f423d9b7b --- /dev/null +++ b/web/tests/integration/modifiers/auto-height-textarea-test.ts @@ -0,0 +1,59 @@ +import { fillIn, find, render } from "@ember/test-helpers"; +import { module, test } from "qunit"; +import { hbs } from "ember-cli-htmlbars"; +import { setupRenderingTest } from "ember-qunit"; +import { assert as emberAssert } from "@ember/debug"; + +module("Integration | Modifier | auto-height-textarea", function (hooks) { + setupRenderingTest(hooks); + + test("it updates the height of the textarea", async function (assert) { + await render(hbs` +