primereact icon indicating copy to clipboard operation
primereact copied to clipboard

Datatable Cell edit manipulates data (not pure)

Open sja-cslab opened this issue 1 year ago • 0 comments

Describe the bug

I've found the inner function optionCallback within datatable that seems to manipulate my data in a not pure way. Here's the function:

var editorCallback = function editorCallback(val) {
    var editingRowData = _objectSpread$a({}, editingRowDataState);
    ObjectUtils.mutateFieldData(editingRowData, field, val);
    setEditingRowDataState(editingRowData);

    // update editing meta for complete methods on row mode
    var currentData = getEditingRowData();
    if (currentData) {
      ObjectUtils.mutateFieldData(currentData, field, val);
    }
  };

That has been build because of this Issue.

In the Docs it says

[...] and implementing onCellEditComplete to update the state

What even the example is not doing in any way.

Reproducer

https://stackblitz.com/run?file=src%2FApp.jsx

PrimeReact version

10.6.6

React version

18.x

Language

ALL

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

sja-cslab avatar Jun 07 '24 12:06 sja-cslab