diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index 1d72dcd79..7c15d19f4 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -1274,6 +1274,20 @@ html.theming, html.theming *, html.theming *::before, html.theming *::after { .modal .dialog.swap { animation: content-in .22s var(--ease); } .modal.out .dialog { animation: dialog-out .16s var(--ease) forwards; } .modal .dialog::-webkit-scrollbar { width: 0; } +/* In a dialog the editor's head and buttons stay put and only the fields + between them scroll; both bars are the same height, their contents + centred in it. */ +.modal .dialog { display: flex; flex-direction: column; } +.modal .editor.framed { display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 0; min-height: 0; overflow: hidden; } +.modal .editor.framed > .ebody { + flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; + display: grid; grid-template-columns: inherit; gap: 10px 14px; align-items: start; padding: 14px 18px; +} +.modal .editor.framed > .ebody::-webkit-scrollbar { width: 0; } +.modal .editor.framed > .ehead, .modal .editor.framed > .bar { flex: none; min-height: 48px; margin: 0; padding: 0 18px; } +.modal .editor.framed > .ehead { border-bottom: 1px solid var(--line-2); } +.modal .editor.framed > .bar { border-top: 1px solid var(--line-2); } +.modal .editor.framed > .editor-error { flex: none; padding: 8px 18px; border-top: 1px solid var(--line-2); } /* Keep native window chrome outside the scrim and dialog. In particular, the macOS traffic lights must never sit on top of modal content. */ body.window.mac .modal { top: 50px; padding: 16px 24px 24px; } diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 27736ca69..2331f6e3e 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -2376,9 +2376,22 @@ function openModal(content) { clearTimeout(modalTimer); m.classList.remove("out"); d.classList.remove("swap"); + const top = m.hidden ? 0 : d.querySelector(".ebody")?.scrollTop || 0; if (!m.hidden) { void d.offsetWidth; d.classList.add("swap"); } // content changed: a soft refresh, not a re-entrance + frame(content); d.replaceChildren(content); m.hidden = false; + const body = content.querySelector(":scope > .ebody"); + if (body) body.scrollTop = top; // a re-render keeps the place +} +// frame holds an editor's head and its buttons still while the fields +// between them scroll. +function frame(ed) { + if (!ed.matches(".editor") || ed.querySelector(":scope > .ebody")) return; + const body = el("div", "ebody"); + body.append(...[...ed.children].filter((c) => !c.matches(".ehead, .bar"))); + ed.querySelector(":scope > .bar") ? ed.querySelector(":scope > .bar").before(body) : ed.append(body); + ed.classList.add("framed"); } function closeModal() { const m = $("#modal");