Revert "fix(ui): allow manual prompt bar resize (#1201)"
This reverts commit 258e6fc0d4.
This commit is contained in:
@@ -519,20 +519,7 @@ export function getAutoScroll() {
|
|||||||
export function autoResize(textarea) {
|
export function autoResize(textarea) {
|
||||||
const lineHeight = parseInt(getComputedStyle(textarea).lineHeight);
|
const lineHeight = parseInt(getComputedStyle(textarea).lineHeight);
|
||||||
const isMobile = window.innerWidth <= 768;
|
const isMobile = window.innerWidth <= 768;
|
||||||
const autoMaxHeight = isMobile ? 150 : lineHeight * 8;
|
const maxHeight = isMobile ? 150 : lineHeight * 8;
|
||||||
|
|
||||||
// Keep a height chosen with the native desktop resize handle. Automatic
|
|
||||||
// changes are recorded before the observer runs, so only a real drag
|
|
||||||
// updates the manual floor.
|
|
||||||
if (!textarea._manualResizeObserver && typeof ResizeObserver !== 'undefined') {
|
|
||||||
textarea._manualResizeObserver = new ResizeObserver(() => {
|
|
||||||
const height = textarea.offsetHeight;
|
|
||||||
if (Math.abs(height - (textarea._autoResizeHeight || height)) > 1) {
|
|
||||||
textarea._manualResizeHeight = height;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
textarea._manualResizeObserver.observe(textarea);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use a hidden clone to measure without disrupting the real textarea
|
// Use a hidden clone to measure without disrupting the real textarea
|
||||||
let clone = textarea._resizeClone;
|
let clone = textarea._resizeClone;
|
||||||
@@ -552,12 +539,9 @@ export function autoResize(textarea) {
|
|||||||
clone.style.width = textarea.offsetWidth + 'px';
|
clone.style.width = textarea.offsetWidth + 'px';
|
||||||
clone.value = textarea.value;
|
clone.value = textarea.value;
|
||||||
clone.style.height = '0';
|
clone.style.height = '0';
|
||||||
const manualHeight = textarea._manualResizeHeight || 0;
|
const newHeight = Math.min(Math.max(clone.scrollHeight, lineHeight), maxHeight);
|
||||||
const maxHeight = Math.max(autoMaxHeight, manualHeight);
|
|
||||||
const newHeight = Math.min(Math.max(clone.scrollHeight, lineHeight, manualHeight), maxHeight);
|
|
||||||
textarea._autoResizeHeight = newHeight;
|
|
||||||
textarea.style.height = newHeight + 'px';
|
textarea.style.height = newHeight + 'px';
|
||||||
textarea.style.overflow = newHeight >= autoMaxHeight ? 'auto' : 'hidden';
|
textarea.style.overflow = newHeight >= maxHeight ? 'auto' : 'hidden';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2204,12 +2204,12 @@ body.bg-pattern-sparkles {
|
|||||||
background: transparent;
|
background: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
resize: vertical;
|
resize: none;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
color: var(--fg);
|
color: var(--fg);
|
||||||
min-height: 24px;
|
min-height: 24px;
|
||||||
max-height: min(60vh, 600px);
|
max-height: 200px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
transition: height 0.12s ease-out;
|
transition: height 0.12s ease-out;
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
from pathlib import Path
|
|
||||||
|
|
||||||
|
|
||||||
CSS = Path("static/style.css").read_text(encoding="utf-8")
|
|
||||||
UI_JS = Path("static/js/ui.js").read_text(encoding="utf-8")
|
|
||||||
|
|
||||||
|
|
||||||
def test_prompt_bar_exposes_desktop_resize_handle():
|
|
||||||
assert "resize: vertical;" in CSS
|
|
||||||
assert "max-height: min(60vh, 600px);" in CSS
|
|
||||||
|
|
||||||
|
|
||||||
def test_auto_resize_preserves_a_manually_chosen_height():
|
|
||||||
assert "textarea._manualResizeHeight = height;" in UI_JS
|
|
||||||
assert "const manualHeight = textarea._manualResizeHeight || 0;" in UI_JS
|
|
||||||
assert "const maxHeight = Math.max(autoMaxHeight, manualHeight);" in UI_JS
|
|
||||||
Reference in New Issue
Block a user