From c481a7fe5e5fb02d9d265cb7ddcb919eaa38837f Mon Sep 17 00:00:00 2001 From: dingo Date: Wed, 28 Oct 2026 08:30:41 -0400 Subject: [PATCH] fix(admin): keep the region map canvas out of the layout The map canvas is absolutely placed in its stage, so its backing size can never feed back into the page layout, and the backing store is capped at 2x and 4,096 pixels a side; a refused 2D context skips the paint instead of throwing. The tab bar no longer shows a vertical scrollbar, the overlays drop backdrop blur, and the theme icons are HTML entities. Co-Authored-By: Claude Opus 5.5 --- apps/evo-admin-api/portal/app.js | 10 ++++++---- apps/evo-admin-api/portal/index.html | 4 ++-- apps/evo-admin-api/portal/style.css | 9 ++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/evo-admin-api/portal/app.js b/apps/evo-admin-api/portal/app.js index 341998f..ea35a1e 100644 --- a/apps/evo-admin-api/portal/app.js +++ b/apps/evo-admin-api/portal/app.js @@ -885,8 +885,10 @@ async function regionPage(region, params) { const depLayer = (d) => (d.kind === 2 ? channelNames[d.top] : d.kind === 1 ? 'pools' : 'patches'); function geometry() { + // The backing store follows the laid-out size (the canvas is absolutely placed, so its own + // size never feeds back into the layout), at most 2x and 4,096 pixels a side. const rect = canvas.getBoundingClientRect(); - const dpr = window.devicePixelRatio || 1; + const dpr = Math.min(window.devicePixelRatio || 1, 2, 4096 / Math.max(1, rect.width, rect.height)); const w = Math.max(1, Math.round(rect.width * dpr)), hgt = Math.max(1, Math.round(rect.height * dpr)); if (canvas.width !== w || canvas.height !== hgt) { canvas.width = w; canvas.height = hgt; } const [aw, ah] = view ? view.area : [1, 1]; @@ -918,8 +920,9 @@ async function regionPage(region, params) { }; function paint() { - const ctx = canvas.getContext('2d'); const g = geometry(); + const ctx = canvas.getContext('2d'); + if (!ctx) return; // The browser refused a context (lost or out of memory). ctx.fillStyle = css('map-bg'); ctx.fillRect(0, 0, g.w, g.hgt); if (!view) return; @@ -1500,8 +1503,7 @@ async function start() { } if (!(await token())) return signedOut(); const env = document.getElementById('env'); - env.textContent = `World ${config.world}`; - env.hidden = !config.world; + if (env) { env.textContent = `World ${config.world}`; env.hidden = !config.world; } try { const me = await api('/api/me'); document.getElementById('who').textContent = me.email || me.subject; diff --git a/apps/evo-admin-api/portal/index.html b/apps/evo-admin-api/portal/index.html index 7f770c9..cbacb87 100644 --- a/apps/evo-admin-api/portal/index.html +++ b/apps/evo-admin-api/portal/index.html @@ -23,8 +23,8 @@
- - + +
diff --git a/apps/evo-admin-api/portal/style.css b/apps/evo-admin-api/portal/style.css index 03f7f27..3e15065 100644 --- a/apps/evo-admin-api/portal/style.css +++ b/apps/evo-admin-api/portal/style.css @@ -347,7 +347,7 @@ dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; } /* ---------- Region page ---------- */ .region-grid { display: grid; grid-template-columns: minmax(0, 1fr) clamp(420px, 30vw, 560px); gap: 16px; align-items: start; } -@media (max-width: 1150px) { .region-grid { grid-template-columns: 1fr; } } +@media (max-width: 1150px) { .region-grid { grid-template-columns: minmax(0, 1fr); } } .map-card { display: flex; @@ -360,12 +360,11 @@ dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; } box-shadow: var(--shadow); } .map-toolbar { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); } -.map-stage { position: relative; flex: 1; min-height: 0; background: var(--map-bg); } -.map-stage canvas { display: block; width: 100%; height: 100%; cursor: crosshair; } +.map-stage { position: relative; flex: 1; min-height: 0; background: var(--map-bg); overflow: hidden; } +.map-stage canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; cursor: crosshair; } .map-stage canvas.dragging { cursor: grabbing; } .glass { background: var(--map-glass); - backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); @@ -447,7 +446,7 @@ dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; } overflow: hidden; } @media (max-width: 1150px) { .panel { position: static; max-height: none; } } -.tabs { flex: none; display: flex; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); background: var(--panel-2); overflow-x: auto; } +.tabs { flex: none; display: flex; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); background: var(--panel-2); overflow-x: auto; overflow-y: hidden; } .tabs button { border: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0;