[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 <noreply@anthropic.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -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 (_) {}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user