diff --git a/internal/gui/assets/plugins/routing/client.js b/internal/gui/assets/plugins/routing/client.js index 6894b9c87..95bd8b586 100644 --- a/internal/gui/assets/plugins/routing/client.js +++ b/internal/gui/assets/plugins/routing/client.js @@ -4636,6 +4636,7 @@ function routingPage(part) { actsFold = { rs: [...rs], by }; return by; } + const provBoxes = new Map(); // a provider → its box in the accounts' list (renderActs) function renderActs(rs) { // a rest lifted by hand since the request that found it (#1869): the // kept requests still say it, until the next one asks it again. By the @@ -4860,7 +4861,28 @@ function routingPage(part) { setText(actUsage, t("View usage")); unhide(actUsage, !list.length); unhide(actFoot, actMore.hidden && actUsage.hidden); - patch(acts, actsAll ? out : out.filter((b) => !hide.has(b))); + // each provider's blocks in one box of its own: in columns, a + // provider's accounts ran on into the next column under no heading, + // and the line between providers stood over a column's top (the + // owner, 11-07: "布局直接崩坏了"). Kept per provider, so a redraw + // with nothing new moves nothing + const runs = []; + for (const b of actsAll ? out : out.filter((b) => !hide.has(b))) { + const p = meta.get(b).prov, last = runs.at(-1); + if (last && last.p === p) last.bs.push(b); else runs.push({ p, bs: [b] }); + } + const boxes = runs.map(({ p, bs }) => { + let g = provBoxes.get(p); + if (!g) provBoxes.set(p, (g = el("div", "rt-pgrp"))); + // its heading's block opened into it: each row no deeper than before + patch(g, bs.flatMap((b) => (b.classList.contains("rt-lead") ? [...b.children] : [b]))); + // hundreds of keys opened (#3164) in one unbroken box would be one + // column as long as all of them: a long one breaks between its rows + const long = bs.reduce((x, b) => x + meta.get(b).n, 0) > 12; + if (g.classList.contains("long") !== long) g.classList.toggle("long", long); + return g; + }); + patch(acts, boxes); } // signInAgain signs the account of seat w in again, in its provider's diff --git a/internal/gui/assets/plugins/routing/routing.css b/internal/gui/assets/plugins/routing/routing.css index 9d2b820c0..81305c985 100644 --- a/internal/gui/assets/plugins/routing/routing.css +++ b/internal/gui/assets/plugins/routing/routing.css @@ -463,6 +463,9 @@ button.rt-session { cursor: pointer; } line (danzi002 on Discord), two of them still on a phone */ :where(.rt-more:not(.min1150)) .rt-acts, .rt-cols.solo .rt-acts { columns: min(240px, 40vw); column-gap: 0; } :where(.rt-more:not(.min1150)) .rt-acts > *, .rt-cols.solo .rt-acts > * { break-inside: avoid; } +:where(.rt-more:not(.min1150)) .rt-pgrp.long, .rt-cols.solo .rt-pgrp.long { break-inside: auto; } +:where(.rt-more:not(.min1150)) .rt-pgrp.long > *, .rt-cols.solo .rt-pgrp.long > * { break-inside: avoid; } +:where(.rt-more:not(.min1150)) .rt-pgrp.long > .rt-prov, .rt-cols.solo .rt-pgrp.long > .rt-prov { break-after: avoid; } .rt-cols.solo { grid-template-columns: minmax(0, 1fr); } .rt-reqs.none { display: block; background: none; border-color: transparent; } .rt-reqs.none .empty-state { padding: 14px 12px 18px; font-size: 12px; line-height: 1.6; } @@ -470,7 +473,11 @@ button.rt-session { cursor: pointer; } .rt-prov { display: flex; align-items: center; gap: 7px; padding: 8px 12px 4px; font-size: 12px; } .rt-prov .ic, .rt-prov .ic img, .rt-prov .ic svg { width: 14px; height: 14px; } .rt-prov > span:last-child { margin-left: auto; font-size: 10.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; } -.rt-acts > :not(:first-child) > .rt-prov:first-child { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; } +/* a provider's heading and rows, one box (.rt-pgrp); one to a line, a + line between providers; in columns a gap instead, a line standing over + a column's top */ +.rt-pgrp + .rt-pgrp { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 2px; } +:where(.rt-more:not(.min1150)) .rt-pgrp + .rt-pgrp, .rt-cols.solo .rt-pgrp + .rt-pgrp { border-top: 0; margin-top: 0; padding-top: 6px; } /* a routing named where it can be changed: a way to where it is set */ .rt-go { cursor: pointer; } .rt-go::after { content: " ›"; } diff --git a/internal/gui/tests/routing-accounts-narrow.test.cjs b/internal/gui/tests/routing-accounts-narrow.test.cjs index abcede972..3b78cc9f9 100644 --- a/internal/gui/tests/routing-accounts-narrow.test.cjs +++ b/internal/gui/tests/routing-accounts-narrow.test.cjs @@ -77,7 +77,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", return { top: Math.round(b.top), left: b.left, right: b.right, text: e.textContent }; })); const settle = () => page.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => setTimeout(r, 100))))); - for (const width of [700, 560, 420]) { + for (const width of [1100, 700, 560, 420]) { await page.setViewportSize({ width, height: 1200 }); await settle(); const reqs = await page.locator(".rt-reqs").boundingBox(), acts = await page.locator(".rt-acts").boundingBox(); @@ -95,6 +95,16 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", // the providers in two columns or more, not a heading to a line const cols = new Set(heads.map((h) => Math.round(h.left))); assert(cols.size >= 2, `${width}px: the providers in columns: ${[...cols]}`); + // a provider's accounts all in its heading's column, none run on + // into the next under no heading, and no line between providers + // over a column's top (the owner, 11-07: "布局直接崩坏了") + const strays = await page.locator(".rt-acts .rt-act").evaluateAll((es) => es.filter((e) => { + const h = e.closest(".rt-acts > *")?.querySelector(".rt-prov"); + return !h || Math.abs(h.getBoundingClientRect().left - e.getBoundingClientRect().left) > 1; + }).map((e) => e.textContent)); + assert.deepEqual(strays, [], `${width}px: accounts away from their heading`); + const lines = await page.locator(".rt-acts > *").evaluateAll((es) => es.filter((e) => parseFloat(getComputedStyle(e).borderTopWidth) > 0).length); + assert.equal(lines, 0, `${width}px: no line over a provider in columns`); const items = await page.locator(".rt-acts > *").evaluateAll((es) => es.reduce((x, e) => x + e.getBoundingClientRect().height, 0)); assert(acts.height < items * 0.7, `${width}px: the list shorter than its items one under the other: ${acts.height} vs ${items}`); assert.equal(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth), false, `${width}px: no horizontal overflow`);