From 44e0e871d4d783672991a815f2a0e886318a7eb6 Mon Sep 17 00:00:00 2001 From: Tammo ter Hark Date: Wed, 25 Nov 2026 21:25:07 +0100 Subject: [PATCH] fix(options): guard JSON.parse of optionCssFiles so the options page works at global level On the GLOBAL theme options page the hidden #optionCssFiles holds the literal string "inherit" (not JSON). options.js did an unguarded JSON.parse($('#optionCssFiles').val()) in the ThemeOptions constructor, which threw and meant run() never executed: no change handlers and no save handler were bound, so Save posted the stale options JSON and nothing changed in the UI (e.g. colors on the Default fonts and colors tab) was saved. Fall back to an empty file list on parse failure. OPTIONS_JS_TOKEN bumped to 20261125.4. Verified against the live page (themeOptions/update&id=497, where optionCssFiles="inherit"): constructor no longer throws, picker input/change handlers bind, and the save click writes the new color into TemplateConfiguration[options]; real HTTP POST confirmed the value lands in lime_template_configuration. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- options/options.js | 12 +++++++++++- options/options.twig | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/options/options.js b/options/options.js index ace04fe..b90b6cc 100644 --- a/options/options.js +++ b/options/options.js @@ -19,7 +19,17 @@ var ThemeOptions = function () { "general_inherit": 1 } - var optionCssFiles = JSON.parse($('#optionCssFiles').val()); + // THEME FIX: on the GLOBAL theme-options page the hidden #optionCssFiles can + // hold the literal string "inherit" (not JSON) — an unguarded JSON.parse then + // throws inside this constructor, so run() never executes: no change handlers + // and no save handler get bound, and Save silently posts the stale options + // JSON (nothing changed in the UI is saved). Fall back to an empty file list. + var optionCssFiles; + try { + optionCssFiles = JSON.parse($('#optionCssFiles').val()); + } catch (e) { + optionCssFiles = { add: [], replace: [], remove: [] }; + } //get the global form var globalForm = $('.action_update_options_string_form'); diff --git a/options/options.twig b/options/options.twig index 41f4901..65ed7b6 100644 --- a/options/options.twig +++ b/options/options.twig @@ -43,7 +43,7 @@ heuristically cached copy (the file has only Last-Modified/ETag, no Cache-Control). Re-register it with a version token: bump OPTIONS_JS_TOKEN below whenever options/options.js changes, so every browser fetches the new file once. #} -{% set OPTIONS_JS_TOKEN = '20261125.3' %} +{% set OPTIONS_JS_TOKEN = '20261125.4' %} {{ unregisterScriptFile(optionsPath ~ '/options.js') }} {{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }}