Skip to content

Commit

Permalink
update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tongsonbarbs committed Dec 10, 2024
1 parent 3063132 commit 9cd1b96
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ test('DataGrid - Canceled rows are hidden when multiple rows are added in batch
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
const addBtn = dataGrid.getToolbar().getItem();
const saveBtn = dataGrid.getToolbar().getItem(1);
await t.expect(dataGrid.isReady()).ok();
await t
.click(addBtn)
.pressKey('1')
Expand All @@ -192,7 +193,7 @@ test('DataGrid - Canceled rows are hidden when multiple rows are added in batch
const overlay2 = new Overlay(Selector('.dx-overlay-wrapper'), 1);
const cancelBtn = overlay2.getToolbar(1).getItem(1);
const saveBtnPopup = overlay1.getToolbar(1).getItem(0);

await t.expect(dataGrid.isReady()).ok();
await t
.click(cancelBtn)
.click(saveBtnPopup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ interface Item {
values?: unknown[];
visible?: boolean;
isExpanded?: boolean;
isNewRow: boolean;
isNewRow?: boolean;
summaryCells?: unknown[];
rowIndex?: number;
cells?: unknown[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,7 @@ class EditingControllerImpl extends modules.ViewController {
hasSavedData = !cancel;

if (!cancel && change?.type === DATA_EDIT_DATA_INSERT_TYPE) {
this._updateUnsavedRowsInsertKey(results[i].key, changes);
this._updateUnsavedRowsInsertKey(results[i].key, results, changes);
}
}
}
Expand All @@ -1713,9 +1713,11 @@ class EditingControllerImpl extends modules.ViewController {
return hasSavedData;
}

private _updateUnsavedRowsInsertKey(tempKey, changes: any[]) {
const topSavedRowKey = this._getTopSavedRowKey();
if (!topSavedRowKey) return;
private _updateUnsavedRowsInsertKey(tempKey, results, changes: any[]) {
let topSavedRowKey = this._getTopSavedRowKey();
if (!topSavedRowKey) {
topSavedRowKey = this._getNewSavedTopRowKey(results);
}

changes.forEach((unsavedChange) => {
if (
Expand All @@ -1732,6 +1734,15 @@ class EditingControllerImpl extends modules.ViewController {
return savedRows.length ? savedRows[0].key : null;
}

private _getNewSavedTopRowKey(results) {
for (const result of results) {
if (result.result && result.result !== 'cancel' && result.result.ID) {
return result.result.ID;
}
}
return null;
}

private _fireSaveEditDataEvents(changes) {
each(changes, (_, { data, key, type }) => {
const internalData = this._addInternalData({ key });
Expand Down

0 comments on commit 9cd1b96

Please sign in to comment.