fix(dashboard): preserve checked meta-input checkboxes across MetaInputsChanged re-renders

renderMetaInputs snapshots the set of checked data-meta-input values before
calling root.replaceChildren(), then restores them after rebuilding the list.

Without this, a MetaInputsChanged SSE event (e.g. fired when a concurrent
meta-update completes) would silently wipe any checkboxes the operator had
ticked but not yet submitted — forcing them to re-select their inputs.
This commit is contained in:
iris 2026-06-05 13:35:04 +02:00 committed by mara
commit 6c57b2b4e0

View file

@ -2364,6 +2364,14 @@ window.marked = marked;
function renderMetaInputs(s) {
const root = $('meta-inputs-section');
if (!root) return;
// Snapshot which checkboxes the operator has ticked before wiping the
// DOM. A MetaInputsChanged event (e.g. triggered by a concurrent
// meta-update completing) would otherwise silently clear pending
// selections mid-flight. We restore them after rebuilding the list.
const checkedInputs = new Set(
Array.from(root.querySelectorAll('input[type="checkbox"][data-meta-input]:checked'))
.map((cb) => cb.dataset.metaInput),
);
root.replaceChildren();
const inputs = s.meta_inputs || [];
if (!inputs.length) {
@ -2410,6 +2418,7 @@ window.marked = marked;
value: inp.name,
'data-meta-input': inp.name,
});
if (checkedInputs.has(inp.name)) cb.checked = true;
const label = el('label', { for: id, title: inp.name });
label.append(cb);
if (depth > 0) label.append(el('span', { class: 'meta-input-twig' }, '└ '));