From ac9382d12ee4a277a7036702f6d34627df7df4d8 Mon Sep 17 00:00:00 2001 From: Bruno Charest Date: Sat, 6 Jun 2026 00:18:11 -0400 Subject: [PATCH] fix: auto-height on file load so entire content is visible Added autoHeight() helper called after ta.value is set in both demo mode and API load. Previously only triggered on input event, so loaded files only showed first line (scrollHeight was 0 until user typed). --- frontend/editor-poc.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/editor-poc.html b/frontend/editor-poc.html index d9614b6..13d17dd 100644 --- a/frontend/editor-poc.html +++ b/frontend/editor-poc.html @@ -491,6 +491,7 @@ body { font-family: var(--sans); background: var(--bg); color: var(--text); heig if (!fileVault || !filePath) { // Demo mode ta.value = '# Demo Document\n\nType **/** for commands. Select text for formatting.\n\n## Features\n\n- Slash commands: type / at start of line\n- Bubble menu: select text\n- AI actions: use the sparkle button or slash /ai\n- Preview: click the eye button\n'; + autoHeight(); statFile.textContent = 'Demo mode'; document.title = 'ObsiGate Forge — Demo'; originalContent = ta.value; @@ -506,6 +507,7 @@ body { font-family: var(--sans); background: var(--bg); color: var(--text); heig }) .then(function(data) { ta.value = data.raw || ''; + autoHeight(); originalContent = ta.value; // Extract title from first # heading or filename var title = filePath.split('/').pop().replace(/\.md$/, ''); @@ -1058,10 +1060,14 @@ body { font-family: var(--sans); background: var(--bg); color: var(--text); heig ta.addEventListener('input', function() { updateStats(); markDirty(); - // Auto-height: grow textarea to fit content (no double scrollbar) + autoHeight(); + }); + + // ---- Auto-height textarea ---- + function autoHeight() { ta.style.height = 'auto'; ta.style.height = ta.scrollHeight + 'px'; - }); + } ta.addEventListener('mouseup', function() { setTimeout(showBubble, 50); }); // Bubble follows cursor on any selection change (keyboard too) document.addEventListener('selectionchange', function() {