From f8be98bc8ae9b3d93534978e6b0bd8e287c13a9a Mon Sep 17 00:00:00 2001 From: yetone Date: Mon, 28 Sep 2026 17:30:36 +0800 Subject: [PATCH] =?UTF-8?q?gui:=20a=20dialog's=20head=20and=20buttons=20st?= =?UTF-8?q?ay=20put=20and=20only=20the=20fields=20between=20them=20scroll?= =?UTF-8?q?=20=E2=80=94=20openModal=20lays=20an=20editor=20out=20as=20head?= =?UTF-8?q?,=20body,=20bar=20(the=20fields=20moved=20into=20.ebody,=20the?= =?UTF-8?q?=20only=20part=20that=20scrolls,=20and=20a=20re-render=20keeps?= =?UTF-8?q?=20its=20place),=20and=20the=20head=20and=20the=20button=20bar?= =?UTF-8?q?=20are=20the=20same=2048px=20with=20what's=20in=20them=20centre?= =?UTF-8?q?d,=20so=20they=20sit=20the=20same=20above=20and=20below=20(?= =?UTF-8?q?=E4=B8=8A=E8=BE=B9=E6=A0=8F=E8=B7=9F=E4=B8=8B=E8=BE=B9=E6=A0=8F?= =?UTF-8?q?=E8=A6=81=E5=9B=BA=E5=AE=9A=E7=9D=80=EF=BC=8C=E5=8F=AA=E6=9C=89?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E5=8C=BA=E5=8F=AF=E4=BB=A5=E4=B8=8A=E4=B8=8B?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=20/=20=E4=B8=8A=E4=B8=8B=E9=97=B4=E8=B7=9D?= =?UTF-8?q?=E8=A6=81=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/gui/assets/app.css | 14 ++++++++++++++ internal/gui/assets/app.js | 13 +++++++++++++ 2 files changed, 27 insertions(+) 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");