Skip to content

Commit 3aeec35

Browse files
authored
Update utils.js
1 parent 7cad0b5 commit 3aeec35

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

utils.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export async function prompt2(specs, opts={}) {
6060
<div style="margin:0.5rem 0; margin-top:${i==0 ? 0 : 1}rem; font-size:85%;">${spec.label}</div>
6161
<div style="display:flex;">
6262
<div style="flex-grow:1;">
63-
<textarea data-spec-key="${sanitizeHtml(key)}" data-height="fit-content" style="width:100%; ${spec.height === "fit-content" ? "" : `height:${spec.height}`}; min-height:4rem; border: 1px solid lightgrey; border-radius: 3px;" type="text" placeholder="${sanitizeHtml(spec.placeholder)}">${sanitizeHtml(spec.defaultValue)}</textarea>
63+
<textarea data-spec-key="${sanitizeHtml(key)}" data-height="fit-content" style="width:100%; ${spec.height === "fit-content" ? "" : `height:${spec.height}`}; min-height:${spec.minHeight ?? "4rem"}; border: 1px solid lightgrey; border-radius: 3px;" type="text" placeholder="${sanitizeHtml(spec.placeholder)}">${sanitizeHtml(spec.defaultValue)}</textarea>
6464
</div>
6565
</div>
6666
</section>`;
@@ -91,7 +91,10 @@ export async function prompt2(specs, opts={}) {
9191
document.body.appendChild(ctn);
9292

9393
setTimeout(() => { // settimeout to ensure rendered
94-
ctn.querySelectorAll("textarea[data-height=fit-content]").forEach(el => el.style.height = Math.max(70, (el.scrollHeight+5)) + "px");
94+
ctn.querySelectorAll("textarea[data-height=fit-content]").forEach(el => {
95+
let minHeight = el.offsetHeight; // textareas will always have min-height set, so we can use that via offsetHeight
96+
el.style.height = Math.max(minHeight, (el.scrollHeight+5)) + "px";
97+
});
9598
}, 10);
9699

97100
let values = await new Promise((resolve) => {

0 commit comments

Comments
 (0)