Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,13 @@ export class FullRowEditStrategy extends BaseEditStrategy {
}

if (!rowsMatch && !preventNavigation) {
this.editSvc?.stopEditing({ rowNode: prevCell.rowNode }, { event });
this.cleanupEditors(nextCell, true);
// force a commit before row editing stops so cellValueChanged fires before rowEditingStopped.
this.editSvc?.stopEditing({ rowNode: prevCell.rowNode }, { event, forceStop: true });

// if nothing was committed, editors may still be open; close them to finish the row edit.
if (this.editSvc?.isRowEditing(prevCell.rowNode, { withOpenEditor: true })) {
this.cleanupEditors(nextCell, true);
}

if (suppressStartEditOnTab) {
nextCell.focusCell(true, event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,49 @@ describe('Cell Editing: undo/redo', () => {
});
}
);

test('full-row tabbing to the next row captures undo actions', async () => {
const api = await gridMgr.createGridAndWait('cellEditingFullRowUndoOnTab', {
editType: 'fullRow',
undoRedoCellEditing: true,
defaultColDef: { editable: true, cellDataType: false },
columnDefs: [{ field: 'a' }, { field: 'b' }],
rowData: [
{ id: 'ROW_0', a: 'A0', b: 'B0' },
{ id: 'ROW_1', a: 'A1', b: 'B1' },
],
getRowId: (params) => params.data.id,
});

const gridDiv = getGridElement(api)! as HTMLElement;
const user = userEvent.setup({ skipHover: true });
await asyncSetTimeout(0);

const row0CellA = getByTestId(gridDiv, agTestIdFor.cell('ROW_0', 'a'));
await user.dblClick(row0CellA);
const input = await waitForInput(gridDiv, row0CellA);
await user.clear(input);
await user.type(input, 'A0-EDIT');

await user.keyboard('{Tab}{Tab}');

const row1CellA = getByTestId(gridDiv, agTestIdFor.cell('ROW_1', 'a'));
await waitForInput(gridDiv, row1CellA);
api.stopEditing();
await asyncSetTimeout(0);

expect(getByTestId(gridDiv, agTestIdFor.cell('ROW_0', 'a'))).toHaveTextContent('A0-EDIT');
expect(api.getCurrentUndoSize()).toBe(1);

api.undoCellEditing();
await asyncSetTimeout(0);
expect(getByTestId(gridDiv, agTestIdFor.cell('ROW_0', 'a'))).toHaveTextContent('A0');

expect(api.getCurrentUndoSize()).toBe(0);

api.redoCellEditing();
await asyncSetTimeout(0);
expect(getByTestId(gridDiv, agTestIdFor.cell('ROW_0', 'a'))).toHaveTextContent('A0-EDIT');
expect(api.getCurrentUndoSize()).toBe(1);
});
});
Loading