@topconsultnpm/sdkui-react 6.22.0-dev2.25 → 6.22.0-dev2.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -61,6 +61,9 @@ export const useMultiMasterDetailDcmts = ({ dtd, masterDcmt, onClose }) => {
61
61
  const [masterInfoReloadToken, setMasterInfoReloadToken] = useState(0);
62
62
  // Righe del riepilogo
63
63
  const [archiveRows, setArchiveRows] = useState([]);
64
+ // La modifica in cella aggiorna la riga fuori dallo stato (vedi updateRowValues)
65
+ const archiveRowsRef = useRef(archiveRows);
66
+ archiveRowsRef.current = archiveRows;
64
67
  const rowIdRef = useRef(0);
65
68
  const [focusedRowKey, setFocusedRowKey] = useState(undefined);
66
69
  const [selectedRowKeys, setSelectedRowKeys] = useState([]);
@@ -354,36 +357,35 @@ export const useMultiMasterDetailDcmts = ({ dtd, masterDcmt, onClose }) => {
354
357
  };
355
358
  /**
356
359
  * Modifica diretta in griglia di uno o più metadati testuali o numerici (changes: mid -> valore).
357
- * La riga e i suoi __values sono ricreati: il duplicato, che condivide __values per
358
- * riferimento, resta invariato
360
+ * La riga è aggiornata sul posto e non con setArchiveRows: un nuovo riferimento all'array
361
+ * ricaricherebbe la griglia a ogni cella confermata, perdendo il clic sulla cella successiva.
362
+ * L'array __values è sostituito, non modificato: il duplicato, che lo condivide, resta invariato
359
363
  */
360
364
  const updateRowValues = useCallback((rowId, changes) => {
361
365
  const changedMids = Object.keys(changes);
362
366
  if (changedMids.length === 0)
363
367
  return;
368
+ const row = archiveRowsRef.current.find(r => r.id === rowId);
369
+ if (!row)
370
+ return;
364
371
  // I __values vanno a sistema come stringhe, anche quelli che in griglia sono numeri. La griglia
365
372
  // restituisce null sull'editor svuotato: a sistema il metadato va vuoto, non nullo
366
373
  const normalized = {};
367
374
  changedMids.forEach(mid => { normalized[mid] = changes[mid] === null || changes[mid] === undefined ? '' : String(changes[mid]); });
368
- setArchiveRows(prev => prev.map(r => {
369
- if (r.id !== rowId)
370
- return r;
371
- const values = r.__values.map(v => (v.mid !== undefined && normalized[String(v.mid)] !== undefined
372
- ? { ...v, value: normalized[String(v.mid)] }
373
- : v));
374
- // Un metadato assente dai valori del form non arriverebbe all'archiviazione
375
- changedMids.filter(mid => !values.some(v => String(v.mid) === mid)).forEach(mid => {
376
- const added = new MetadataValueDescriptorEx();
377
- added.tid = r.__tid;
378
- added.mid = Number(mid);
379
- added.value = normalized[mid];
380
- values.push(added);
381
- });
382
- const updated = { ...r, __values: values };
383
- // In cella il numero resta un numero, come lo vuole il suo editor
384
- changedMids.forEach(mid => { updated[mid] = numericMidsRef.current.has(Number(mid)) ? toGridNumber(normalized[mid]) : normalized[mid]; });
385
- return updated;
386
- }));
375
+ const values = row.__values.map(v => (v.mid !== undefined && normalized[String(v.mid)] !== undefined
376
+ ? { ...v, value: normalized[String(v.mid)] }
377
+ : v));
378
+ // Un metadato assente dai valori del form non arriverebbe all'archiviazione
379
+ changedMids.filter(mid => !values.some(v => String(v.mid) === mid)).forEach(mid => {
380
+ const added = new MetadataValueDescriptorEx();
381
+ added.tid = row.__tid;
382
+ added.mid = Number(mid);
383
+ added.value = normalized[mid];
384
+ values.push(added);
385
+ });
386
+ row.__values = values;
387
+ // In cella il numero resta un numero, come lo vuole il suo editor
388
+ changedMids.forEach(mid => { row[mid] = numericMidsRef.current.has(Number(mid)) ? toGridNumber(normalized[mid]) : normalized[mid]; });
387
389
  }, []);
388
390
  // I __values sono condivisi per riferimento: la modifica sostituisce l'intero array, quindi non intacca il duplicato
389
391
  const duplicateRow = useCallback((row) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.22.0-dev2.25",
3
+ "version": "6.22.0-dev2.26",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",