Skip to content

Commit 797a073

Browse files
committed
fix(grid): Cancel endEdit if there is no active editing
1 parent 0825a92 commit 797a073

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6316,6 +6316,9 @@ export abstract class IgxGridBaseDirective implements GridType,
63166316
// TODO: do not remove this, as it is used in rowEditTemplate, but mark is as internal and hidden
63176317
/* blazorCSSuppress */
63186318
public endEdit(commit = true, event?: Event): boolean {
6319+
if (!this.crudService.cellInEditMode && !this.crudService.rowInEditMode) {
6320+
return;
6321+
}
63196322
const document = this.nativeElement?.getRootNode() as Document | ShadowRoot;
63206323
const focusWithin = this.nativeElement?.contains(document.activeElement);
63216324

projects/igniteui-angular/src/lib/grids/grid/grid-cell-selection.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('IgxGrid - Cell selection #grid', () => {
4343
detect = () => grid.cdr.detectChanges();
4444
});
4545

46-
it('Should be able to select a range with mouse dragging', () => {
46+
fit('Should be able to select a range with mouse dragging', () => {
4747
const selectionChangeSpy = spyOn<any>(grid.rangeSelected, 'emit').and.callThrough();
4848
const startCell = grid.gridAPI.get_cell_by_index(2, 'ParentID');
4949
const endCell = grid.gridAPI.get_cell_by_index(3, 'ID');
@@ -84,6 +84,10 @@ describe('IgxGrid - Cell selection #grid', () => {
8484

8585
UIInteractions.simulatePointerOverElementEvent('pointerup', endCell.nativeElement);
8686
detect();
87+
// Invoke endEdit() to make sure if no editing is going on,
88+
// the cell activation shouldn't be lost (https://infragistics.visualstudio.com/Indigo_Platform/_workitems/edit/37933)
89+
grid.endEdit(true, null);
90+
fix.detectChanges();
8791

8892
expect(startCell.active).toBe(true);
8993
GridSelectionFunctions.verifyCellsRegionSelected(grid, 2, 3, 1, 0);

0 commit comments

Comments
 (0)