From 3d0c5e6e28af03d8f9654c97c7d16b5c84b79b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 22 Oct 2026 15:14:18 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20the=20colour=20panel=20sc?= =?UTF-8?q?ript=20loads=20on=20every=20page,=20and=20the=20custom=20swatch?= =?UTF-8?q?=20shows=20the=20stored=20hue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/forge-web/assets/nav.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/forge-web/assets/nav.js b/crates/forge-web/assets/nav.js index 869814a..33b2e92 100644 --- a/crates/forge-web/assets/nav.js +++ b/crates/forge-web/assets/nav.js @@ -837,6 +837,13 @@ // swap, because the swap restores it as a changed field. Each panel is set up once; after that its // shown panel follows its tab radios. Called on every page change (see `enhance`). function enhanceColours() { + // The server renders each stripe's stored hue as the range value only, so the row's `--hue` (which + // the Custom swatch reads) is set here from that value. Each row is set through the CSSOM because + // the CSP forbids inline style attributes from the server. + document.querySelectorAll('.hue-row').forEach(function (row) { + var range = row.querySelector('input[data-hue-stripe]'); + if (range) { row.style.setProperty('--hue', range.value); } + }); document.querySelectorAll('[data-colour-group]').forEach(function (group) { var tabs = group.querySelectorAll('input[data-colour-tab]'); if (!group.__colourTab) { @@ -850,6 +857,8 @@ if (on) { group.setAttribute('data-tab', on.value); } }); } + // The authoring script below runs this from its own `enhance`, so it is shared the way `__forgeQuery` is. + window.__forgeColours = enhanceColours; // A filtered view asked for in place: the URL is replaced (no history entry per change), fields // and caret come through the swap, and the scroll stays put. @@ -1994,7 +2003,7 @@ // ---- toolbar and upload ---- function enhance() { - enhanceColours(); + if (window.__forgeColours) { window.__forgeColours(); } document.querySelectorAll('textarea').forEach(function (ta) { if (ta.__md || !eligible(ta)) { return; } ta.__md = true;