diff --git a/chrome.html b/chrome.html index b1a91c80..c99c9913 100644 --- a/chrome.html +++ b/chrome.html @@ -1106,16 +1106,28 @@ } // In-page prompt modal — window.prompt is disabled in Electron BrowserViews. // Resolves to the trimmed string on OK, or null on Cancel / Escape / mask click. + // The chrome view is only as tall as its rows, and a fixed-position mask + // adds nothing to body.scrollHeight — so a prompt taller than the rows was + // cut off at the view's edge (the two-field favorites form lost its title + // and buttons). Grow the view to fit the box while a prompt is open; + // done() calls syncHeight() to shrink it back. + function growForPrompt(mask) { + try { + const box = mask.querySelector(".promptbox"); + const need = box ? Math.ceil(box.getBoundingClientRect().height) + 56 : 0; + T.setChromeHeight(Math.max(document.body.scrollHeight, need)); + } catch {} + } function inPrompt(label, initial) { return new Promise((resolve) => { const mask = document.createElement("div"); mask.className = "promptmask"; mask.innerHTML = `
${label.replace(/` + `` + `
`; - document.body.appendChild(mask); + document.body.appendChild(mask); growForPrompt(mask); const input = mask.querySelector("input"); input.value = String(initial ?? ""); - const done = (val) => { try { mask.remove(); } catch {} document.removeEventListener("keydown", key); resolve(val); }; + const done = (val) => { try { mask.remove(); } catch {} document.removeEventListener("keydown", key); syncHeight(); resolve(val); }; const key = (e) => { if (e.key === "Escape") done(null); else if (e.key === "Enter") done(input.value.trim() || null); }; document.addEventListener("keydown", key); mask.addEventListener("mousedown", (e) => { if (e.target === mask) done(null); }); @@ -1148,7 +1160,7 @@ + `
` + `` + `
`; - document.body.appendChild(mask); + document.body.appendChild(mask); growForPrompt(mask); const url = mask.querySelector(".purl"), title = mask.querySelector(".ptitle"), err = mask.querySelector(".perr"); url.value = String(initial.url ?? ""); title.value = String(initial.title ?? ""); let titleTouched = !!title.value; @@ -1160,7 +1172,7 @@ }; url.addEventListener("input", autoTitle); title.addEventListener("input", () => { titleTouched = title.value.trim().length > 0; if (!titleTouched) autoTitle(); }); - const done = (val) => { try { mask.remove(); } catch {} document.removeEventListener("keydown", key); resolve(val); }; + const done = (val) => { try { mask.remove(); } catch {} document.removeEventListener("keydown", key); syncHeight(); resolve(val); }; const submit = () => { const norm = normalizeBookmarkUrl(url.value); if (!norm) { err.textContent = "That doesn't look like a web address."; err.hidden = false; url.focus(); return; }