Skip to content

Commit 081caae

Browse files
authored
Merge pull request #4793 from Tyoneb/fix-issue-4723
Fix row data update workflow to properly trigger cells update events of uninitialized cells (#4723)
2 parents a26a738 + 6704d2d commit 081caae

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

src/js/core/row/Row.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,12 @@ export default class Row extends CoreFeature{
267267
}
268268

269269
newRowData = this.chain("row-data-changing", [this, tempData, updatedData], null, updatedData);
270-
271-
//set data
272-
for (let attrname in newRowData) {
273-
this.data[attrname] = newRowData[attrname];
274-
}
275-
276-
this.dispatch("row-data-save-after", this);
277-
278-
//update affected cells only
270+
271+
// compute cells to update
272+
// This must be done prior to updating the row data otherwise uninitialized cells get
273+
// generated directly with the updated data, which prevents the run of callbacks
274+
// registered on cells updates (e.g. mutators)
275+
const cellsToUpdate = [];
279276
for (let attrname in updatedData) {
280277

281278
let columns = this.table.columnManager.getColumnsByFieldRoot(attrname);
@@ -286,16 +283,28 @@ export default class Row extends CoreFeature{
286283
if(cell){
287284
let value = column.getFieldValue(newRowData);
288285
if(cell.getValue() !== value){
289-
cell.setValueProcessData(value);
290-
291-
if(visible){
292-
cell.cellRendered();
293-
}
286+
cellsToUpdate.push([cell, value]);
294287
}
295288
}
296289
});
297290
}
298291

292+
//set data
293+
for (let attrname in newRowData) {
294+
this.data[attrname] = newRowData[attrname];
295+
}
296+
297+
this.dispatch("row-data-save-after", this);
298+
299+
//update affected cells only
300+
cellsToUpdate.forEach(([cell, value]) => {
301+
cell.setValueProcessData(value);
302+
303+
if(visible){
304+
cell.cellRendered();
305+
}
306+
});
307+
299308
//Partial reinitialization if visible
300309
if(visible){
301310
this.normalizeHeight(true);

0 commit comments

Comments
 (0)