fix(options): custom color picker group — equal-height parts, no third "effective" swatch

Row 143: the input group of a color-chooser's custom picker (shown when "Other
..." is chosen) had three parts and two problems:
1. The text input was lower than the swatch part (.input-group-text holding
   input[type=color], whose default height exceeds the form-control line box).
   Fixed in the inline <style> of options.twig: the color input is set to the
   same line box as .form-control (height: 1.5em), so swatch part and text
   input are both calc(1.5em + 0.75rem + 2px) tall.
2. The third part — the appended "effective color" swatch
   (.color-mode-effective) — is removed entirely (options.js refreshEffective /
   effectiveColor deleted, CSS rule deleted). The group is now just swatch +
   text input.
OPTIONS_JS_TOKEN -> 20261126.18. Verified: render tc=663 (no color-mode-effective
in the page, options.js?v=20261126.18), jsdom 7/7 incl. new pins (no third part
in the DOM at load or after mode changes; equal-height rule present; stale rule
gone), export exit 0. Variants not rebuilt (deferred).

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Tammo ter Hark 2026-11-26 20:09:56 +01:00
commit 02e9babe7c
2 changed files with 17 additions and 28 deletions

View file

@ -771,19 +771,12 @@ var ThemeOptions = function () {
|| sel.find('option').not('[value="inherit"]').first().attr('value') || sel.find('option').not('[value="inherit"]').first().attr('value')
|| ''); || '');
var customInput = globalForm.find('input[name="' + key + 'custom"]'); var customInput = globalForm.find('input[name="' + key + 'custom"]');
var rowLabel = String(sel.closest('.mb-3').find('.form-label').first().text() || key);
var currentColor = function (ckey) { var currentColor = function (ckey) {
var f = globalForm.find('#simple_edit_options_' + ckey); var f = globalForm.find('#simple_edit_options_' + ckey);
var v = f.val(); var v = f.val();
if (!v) { v = f.data('inheritvalue'); } if (!v) { v = f.data('inheritvalue'); }
return v ? String(v) : ''; return v ? String(v) : '';
}; };
var effectiveColor = function () {
var mode = String(sel.val());
if (mode === 'other') { return customInput.length && customInput.val() ? String(customInput.val()) : ''; }
var pk = presets[mode];
return pk ? currentColor(pk) : '';
};
var refreshLabels = function () { var refreshLabels = function () {
sel.find('option').each(function () { sel.find('option').each(function () {
var op = $(this); var op = $(this);
@ -847,19 +840,10 @@ var ThemeOptions = function () {
.toggleClass('is-default', defaultMode !== '' && mode === defaultMode); .toggleClass('is-default', defaultMode !== '' && mode === defaultMode);
}); });
}; };
var refreshEffective = function () { // row 143: NO third part in the input group any more — the "effective color"
var group = customInput.closest('.input-group'); // swatch (.color-mode-effective) is removed; the group is just the swatch
if (!group.length) { return; } // part + the text input, both the same height (CSS in options.twig)
var sw = group.find('.color-mode-effective'); var refreshAll = function () { refreshLabels(); refreshChips(); };
if (!sw.length) {
sw = $('<span class="color-mode-effective"></span>');
group.append($('<div class="input-group-text"></div>').append(sw));
}
var c = effectiveColor();
sw.css('background', c || 'transparent');
sw.attr('title', c ? 'Effective color (' + rowLabel + '): ' + c : 'Effective color (' + rowLabel + '): (none)');
};
var refreshAll = function () { refreshLabels(); refreshChips(); refreshEffective(); };
colorModeRefreshers.push(refreshAll); colorModeRefreshers.push(refreshAll);
// legacy migration: stored hex (pre-dropdown value) -> mode "other" + hex into the custom field // legacy migration: stored hex (pre-dropdown value) -> mode "other" + hex into the custom field
var stored = legacyColorValues[key]; var stored = legacyColorValues[key];

View file

@ -43,7 +43,7 @@
heuristically cached copy (the file has only Last-Modified/ETag, no Cache-Control). 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 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. #} options/options.js changes, so every browser fetches the new file once. #}
{% set OPTIONS_JS_TOKEN = '20261126.17' %} {% set OPTIONS_JS_TOKEN = '20261126.18' %}
{{ unregisterScriptFile(optionsPath ~ '/options.js') }} {{ unregisterScriptFile(optionsPath ~ '/options.js') }}
{{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }} {{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }}
@ -176,14 +176,19 @@
.tab-content h2:not(.modal-title) { .tab-content h2:not(.modal-title) {
font-size: 24px; font-size: 24px;
} }
.color-mode-effective { /* row 143: in the color picker input group the swatch part (.input-group-text
display: inline-block; holding input[type=color]) must be exactly as high as the text input — set
width: 1.1rem; the color input to the same line box (1.5em) as .form-control, so both parts
height: 1.1rem; end up calc(1.5em + 0.75rem + 2px) tall. (The third part of the group, the
border: 1px solid rgba(0, 0, 0, 0.35); appended effective-color swatch, was removed — see options.js.) */
border-radius: 0.25rem; .input-group > .style__colorpicker input[type="color"] {
vertical-align: middle; display: block;
width: 2.5em;
height: 1.5em;
padding: 0;
border: 0;
background: transparent; background: transparent;
cursor: pointer;
} }
</style> </style>