From d519363c8dff35c2b70142129ae7314e8f74c079 Mon Sep 17 00:00:00 2001 From: m Date: Fri, 8 May 2026 11:20:39 +0200 Subject: [PATCH] fix(admin/approval-policies): preserve
open state across re-renders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changing any required_role cell saves the policy and re-renders the units list to refresh the attribution chips, but the re-render rebuilt every
closed — collapsing the accordion the admin was actively editing (m, 2026-05-08 11:19). Capture the set of open data-unit-ids before innerHTML overwrites them, then re-apply the open attribute on the rendered nodes for those ids. Adds data-unit-id to the
as the stable identity. No behavior change for first render or for units the admin hadn't expanded. --- frontend/src/client/admin-approval-policies.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/client/admin-approval-policies.ts b/frontend/src/client/admin-approval-policies.ts index bb66ee5..ae48a5e 100644 --- a/frontend/src/client/admin-approval-policies.ts +++ b/frontend/src/client/admin-approval-policies.ts @@ -208,12 +208,19 @@ function renderUnitMatrix(unit: PartnerUnit): string { function renderUnits(): void { const host = document.getElementById("ap-units-list"); if (!host) return; + // Preserve which unit blocks were expanded across re-renders. Without this, + // changing any cell's required_role saves and re-renders, collapsing the + // accordion the admin was working in (m, 2026-05-08). + const openUnitIDs = new Set(); + host.querySelectorAll("details.ap-unit-block").forEach((d) => { + if (d.open && d.dataset.unitId) openUnitIDs.add(d.dataset.unitId); + }); if (partnerUnits.length === 0) { host.innerHTML = `

${esc(t("admin.approval_policies.units.empty") || "Keine Partner Units vorhanden.")}

`; return; } host.innerHTML = partnerUnits.map((u) => ` -
+
${esc(u.name)} ${esc(u.office)}