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:
parent
e5da9654f1
commit
6c57b2b4e0
1 changed files with 9 additions and 0 deletions
|
|
@ -2364,6 +2364,14 @@ window.marked = marked;
|
||||||
function renderMetaInputs(s) {
|
function renderMetaInputs(s) {
|
||||||
const root = $('meta-inputs-section');
|
const root = $('meta-inputs-section');
|
||||||
if (!root) return;
|
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();
|
root.replaceChildren();
|
||||||
const inputs = s.meta_inputs || [];
|
const inputs = s.meta_inputs || [];
|
||||||
if (!inputs.length) {
|
if (!inputs.length) {
|
||||||
|
|
@ -2410,6 +2418,7 @@ window.marked = marked;
|
||||||
value: inp.name,
|
value: inp.name,
|
||||||
'data-meta-input': inp.name,
|
'data-meta-input': inp.name,
|
||||||
});
|
});
|
||||||
|
if (checkedInputs.has(inp.name)) cb.checked = true;
|
||||||
const label = el('label', { for: id, title: inp.name });
|
const label = el('label', { for: id, title: inp.name });
|
||||||
label.append(cb);
|
label.append(cb);
|
||||||
if (depth > 0) label.append(el('span', { class: 'meta-input-twig' }, '└ '));
|
if (depth > 0) label.append(el('span', { class: 'meta-input-twig' }, '└ '));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue