From 1e40d5e139ad2a7795d5c9344a4b7b0f68a2c5fc Mon Sep 17 00:00:00 2001 From: BFLOWS Date: Sat, 18 Apr 2026 19:36:11 +0200 Subject: [PATCH] fix(istruttoriaPratica): expandedInv array vuoto per DataTable con subheader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Runtime TypeError cliccando ▸ per espandere le note di una fattura: '(collection || []).findIndex is not a function' Causa: la DataTable fatture usa rowGroupMode='subheader' + groupRowsBy. In questa modalita PrimeReact chiama expandedRows.findIndex(...) al toggle della row. Il valore iniziale era {} (oggetto) — findIndex non esiste sull'oggetto → crash alla prima espansione. Fix: useState([]) invece di useState({}). Il reducer di onRowToggle gestisce array/oggetto trasparentemente, ma il bootstrap deve essere un array quando c'e rowGroupMode. La tabella ULA (expandedUla) resta {} perche non usa subheader e PrimeReact accetta entrambi i formati in quella configurazione. Segnalazione Carlo (demo in corso). --- src/modules/rendicontazione/pages/IstruttoriaPratica.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/rendicontazione/pages/IstruttoriaPratica.js b/src/modules/rendicontazione/pages/IstruttoriaPratica.js index 11dd1ee..3405423 100644 --- a/src/modules/rendicontazione/pages/IstruttoriaPratica.js +++ b/src/modules/rendicontazione/pages/IstruttoriaPratica.js @@ -71,7 +71,10 @@ const IstruttoriaPratica = () => { const [previewDialog, setPreviewDialog] = useState({ visible: false, entityType: null, entityId: null, filename: null, title: null }); const [docNoteDialog, setDocNoteDialog] = useState({ visible: false, doc: null, status: null }); // tabelle: expanded rows + buffer modifiche inline - const [expandedInv, setExpandedInv] = useState({}); + // Array vuoto (NON oggetto): in rowGroupMode='subheader' PrimeReact fa + // findIndex su expandedRows, che fallisce con (collection || []).findIndex is not a function + // se il valore iniziale e {}. La tabella ULA (senza subheader) accetta anche l'oggetto. + const [expandedInv, setExpandedInv] = useState([]); const [expandedUla, setExpandedUla] = useState({}); const [invDraft, setInvDraft] = useState({}); // { invoiceId: { amount_verified, notes } } const [ulaDraft, setUlaDraft] = useState({}); // { employeeId: { fte_pct_verified, notes } }