From d96b38e8eafc9d185c1f1c1f31e1530010a134bd Mon Sep 17 00:00:00 2001 From: Webifi Date: Tue, 13 Jun 2023 21:54:11 -0500 Subject: [PATCH] Constrain size of prompt textarea fix #172 --- src/app.scss | 6 ++++-- src/lib/Util.svelte | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app.scss b/src/app.scss index c7d2a98..da7f917 100644 --- a/src/app.scss +++ b/src/app.scss @@ -245,8 +245,6 @@ $modal-background-background-color-dark: rgba($dark, 0.86) !default; // remove t } } - - /* Loading chat messages */ .is-loading { opacity: 0.5; @@ -462,6 +460,10 @@ aside.menu.main-menu .menu-expanse { .control.send .button { width: 60px; } + textarea { + max-height: calc(100vh - (var(--chatContentPaddingBottom) + var(--runningTotalLineHeight) * var(--running-totals))) !important; + min-height: 38px !important; + } } @media only screen and (max-width: 768px) { diff --git a/src/lib/Util.svelte b/src/lib/Util.svelte index e2e4360..39831b8 100644 --- a/src/lib/Util.svelte +++ b/src/lib/Util.svelte @@ -21,6 +21,13 @@ const anyEl = el as any // Oh how I hate typescript. All the markup of Java with no real payoff.. if (!anyEl.__didAutoGrow) el.style.height = '38px' // don't use "auto" here. Firefox will over-size. el.style.height = el.scrollHeight + 'px' + setTimeout(() => { + if (el.scrollHeight > el.getBoundingClientRect().height + 5) { + el.style.overflowY = 'auto' + } else { + el.style.overflowY = '' + } + }, 0) anyEl.__didAutoGrow = true // don't resize this one again unless it's via an event }