fix: auto-height on file load so entire content is visible
CI / lint (push) Successful in 15s
CI / security (push) Successful in 9s
CI / test (push) Successful in 26s
CI / build (push) Successful in 3s

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).
This commit is contained in:
2026-06-06 00:18:11 -04:00
parent ba30d1e7ce
commit ac9382d12e
+8 -2
View File
@@ -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() {