gui: a dialog's head and buttons stay put and only the fields between them scroll — openModal lays an editor out as head, body, bar (the fields moved into .ebody, the only part that scrolls, and a re-render keeps its place), and the head and the button bar are the same 48px with what's in them centred, so they sit the same above and below (上边栏跟下边栏要固定着,只有内容区可以上下滚动 / 上下间距要保持一致)

This commit is contained in:
yetone
2026-09-28 17:30:39 +08:00
parent 5741e3fc95
commit f8be98bc8a
2 changed files with 27 additions and 0 deletions
+14
View File
@@ -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; }
+13
View File
@@ -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");