From 2d1f6350190fb22359871e2ca7626ef79b43a997 Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Sun, 22 Mar 2026 09:29:50 +0100 Subject: [PATCH] [fix](trx-frontend-http): directly re-apply bookmark chip colors on theme change Bumping bmRevision and scheduling a spectrum draw was not enough because the spectrum draw path only runs when spectrum data is present. Instead, directly update --bm-cat-bg/--bm-cat-fg on all existing bookmark chips from the new theme palette so colors update immediately. Co-Authored-By: Claude Opus 4.6 Signed-off-by: Stan Grams --- .../trx-frontend-http/assets/web/app.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js index 7b37a98..23ab722 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js @@ -631,7 +631,21 @@ function setTheme(theme) { themeToggleBtn.title = next === "dark" ? "Switch to light mode" : "Switch to dark mode"; } // Invalidate cached bookmark chip colours so they pick up the new theme palette. - if (typeof bmRevision !== "undefined") bmRevision++; + if (typeof bmRevision !== "undefined") { + bmRevision++; + // Re-apply colours to existing bookmark chips using the new palette. + try { + const colorMap = bmCategoryColorMap(); + const ref = typeof bmList !== "undefined" ? bmList : []; + document.querySelectorAll(".spectrum-bookmark-chip").forEach((chip) => { + const bm = ref.find((b) => b.id === chip.dataset.bmId); + if (!bm) return; + const col = colorMap[bm.category || ""] || BOOKMARK_MARKER_FALLBACK; + chip.style.setProperty("--bm-cat-bg", col); + chip.style.setProperty("--bm-cat-fg", bmContrastFg(col)); + }); + } catch (_) {} + } try { if (typeof scheduleSpectrumDraw === "function") scheduleSpectrumDraw(); } catch (_) {} }