Skip to content

Commit 4becc57

Browse files
authored
Merge pull request #8975 from IgniteUI/dTsvetkov/fix-8818-master
fix(cell selection): Fixed copy-paste behavior #8818
2 parents 156dbe1 + d825c36 commit 4becc57

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -6749,6 +6749,10 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
67496749
selectionMap.push([activeEl.row, new Set<number>().add(activeEl.column)]);
67506750
}
67516751

6752+
if (this.cellSelection === GridSelectionMode.none && activeEl) {
6753+
selectionMap.push([activeEl.row, new Set<number>().add(activeEl.column)]);
6754+
}
6755+
67526756
// eslint-disable-next-line prefer-const
67536757
for (let [row, set] of selectionMap) {
67546758
row = this.paging ? row + (this.perPage * this.page) : row;

projects/igniteui-angular/src/lib/grids/grid-navigation.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export class IgxGridNavigationService {
136136
const shouldClearSelection = hasLastActiveNode && (this.lastActiveNode.row < 0 || this.lastActiveNode.row > gridRows - 1);
137137
this.setActiveNode(this.lastActiveNode.row >= 0 && this.lastActiveNode.row < gridRows ?
138138
this.firstVisibleNode(this.lastActiveNode.row) : this.firstVisibleNode());
139-
if (shouldClearSelection) {
139+
if (shouldClearSelection || (this.grid.cellSelection !== GridSelectionMode.multiple)) {
140140
this.grid.clearCellSelection();
141141
this.grid.navigateTo(this.activeNode.row, this.activeNode.column, (obj) => {
142142
obj.target?.activate(event);

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ describe('IgxGrid - Cell selection #grid', () => {
418418
GridSelectionFunctions.verifyCellsRegionSelected(grid, 0, 2, 1, 2, false);
419419
expect(rangeChangeSpy).toHaveBeenCalledTimes(1);
420420
expect(grid.selectedCells.length).toBe(0);
421-
expect(grid.getSelectedData()).toEqual([]);
421+
expect(grid.getSelectedData().length).toBe(1);
422422
expect(grid.getSelectedRanges()).toEqual([]);
423423
});
424424

@@ -2918,7 +2918,7 @@ describe('IgxGrid - Cell selection #grid', () => {
29182918
GridSelectionFunctions.verifyCellSelected(secondCell, false);
29192919
GridSelectionFunctions.verifyCellSelected(thirdCell, false);
29202920
expect(grid.selectedCells.length).toBe(0);
2921-
expect(grid.getSelectedData()).toEqual([]);
2921+
expect(grid.getSelectedData().length).toBe(1);
29222922
expect(grid.getSelectedRanges()).toEqual([]);
29232923
});
29242924

@@ -2963,7 +2963,7 @@ describe('IgxGrid - Cell selection #grid', () => {
29632963
cell = grid.getCellByColumn(1, 'ParentID');
29642964
GridSelectionFunctions.verifyCellSelected(cell, false);
29652965
expect(grid.selectedCells.length).toBe(0);
2966-
expect(grid.getSelectedData()).toEqual([]);
2966+
expect(grid.getSelectedData().length).toBe(1);
29672967
expect(grid.getSelectedRanges()).toEqual([]);
29682968
});
29692969

@@ -2980,7 +2980,7 @@ describe('IgxGrid - Cell selection #grid', () => {
29802980
GridSelectionFunctions.verifyCellSelected(endCell, false);
29812981
expect(rangeChangeSpy).toHaveBeenCalledTimes(0);
29822982
expect(grid.selectedCells.length).toBe(0);
2983-
expect(grid.getSelectedData()).toEqual([]);
2983+
expect(grid.getSelectedData().length).toBe(1);
29842984
expect(grid.getSelectedRanges()).toEqual([]);
29852985
});
29862986

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('IgxTreeGrid - Multi Cell selection #tGrid', () => {
8080
GridSelectionFunctions.verifyCellsRegionSelected(treeGrid, 0, 2, 0, 0, false);
8181
expect(rangeChangeSpy).toHaveBeenCalledTimes(1);
8282
expect(treeGrid.selectedCells.length).toBe(0);
83-
expect(treeGrid.getSelectedData()).toEqual([]);
83+
expect(treeGrid.getSelectedData().length).toBe(1);
8484
expect(treeGrid.getSelectedRanges()).toEqual([]);
8585
});
8686

0 commit comments

Comments
 (0)