Skip to content

Commit c69b0da

Browse files
authored
Merge pull request #7476 from IgniteUI/ddincheva/bugFixs9.1
Clicking a grid cell should not scrolls the grid to the top
2 parents d3c937c + a96af8e commit c69b0da

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

projects/igniteui-angular/src/lib/grids/cell.component.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,14 +588,12 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
588588

589589
private addPointerListeners(selection) {
590590
if (selection !== GridSelectionMode.multiple) { return; }
591-
this.nativeElement.addEventListener('pointerdown', this.pointerdown);
592591
this.nativeElement.addEventListener('pointerenter', this.pointerenter);
593592
this.nativeElement.addEventListener('pointerup', this.pointerup);
594593
}
595594

596595
private removePointerListeners(selection) {
597596
if (selection !== GridSelectionMode.multiple) { return; }
598-
this.nativeElement.removeEventListener('pointerdown', this.pointerdown);
599597
this.nativeElement.removeEventListener('pointerenter', this.pointerenter);
600598
this.nativeElement.removeEventListener('pointerup', this.pointerup);
601599
}
@@ -606,6 +604,7 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
606604
*/
607605
ngOnInit() {
608606
this.zone.runOutsideAngular(() => {
607+
this.nativeElement.addEventListener('pointerdown', this.pointerdown);
609608
this.addPointerListeners(this.cellSelectionMode);
610609
// IE 11 workarounds
611610
if (isIE()) {
@@ -629,6 +628,7 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
629628
*/
630629
ngOnDestroy() {
631630
this.zone.runOutsideAngular(() => {
631+
this.nativeElement.removeEventListener('pointerdown', this.pointerdown);
632632
this.removePointerListeners(this.cellSelectionMode);
633633
if (isIE()) {
634634
this.nativeElement.removeEventListener('compositionstart', this.compositionStartHandler);
@@ -755,6 +755,10 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
755755
* @internal
756756
*/
757757
pointerdown = (event: PointerEvent) => {
758+
if (this.cellSelectionMode !== GridSelectionMode.multiple) {
759+
this.activate(event);
760+
return;
761+
}
758762
if (!isLeftClick(event)) {
759763
this.selectionService.addKeyboardRange();
760764
this.selectionService.initKeyboardState();
@@ -816,9 +820,6 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
816820
*/
817821
@HostListener('click', ['$event'])
818822
public onClick(event: MouseEvent) {
819-
if (this.cellSelectionMode !== GridSelectionMode.multiple) {
820-
this.activate(event);
821-
}
822823
this.grid.onCellClick.emit({
823824
cell: this,
824825
event

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ describe('IgxGrid - Keyboard navigation #grid', () => {
663663
it('should toggle expand/collapse state of group row with ArrowRight/ArrowLeft key.', () => {
664664
const gRow = grid.groupsRowList.toArray()[0];
665665
const gRowElement = GridFunctions.getGroupedRows(fix)[0];
666-
gRowElement.triggerEventHandler('click', {});
666+
gRowElement.triggerEventHandler('pointerdown', {});
667667
fix.detectChanges();
668668
expect(gRow.expanded).toBe(true);
669669

@@ -680,7 +680,7 @@ describe('IgxGrid - Keyboard navigation #grid', () => {
680680
it('should toggle expand/collapse state of group row with ArrowUp/ArrowDown key.', () => {
681681
const gRow = grid.groupsRowList.toArray()[0];
682682
const gRowElement = GridFunctions.getGroupedRows(fix)[0];
683-
gRowElement.triggerEventHandler('click', {});
683+
gRowElement.triggerEventHandler('pointerdown', {});
684684
fix.detectChanges();
685685

686686
expect(gRow.expanded).toBe(true);
@@ -704,7 +704,7 @@ describe('IgxGrid - Keyboard navigation #grid', () => {
704704
let groupedRowsCount = grid.groupsRowList.length;
705705
let groupRow = grid.groupsRowList.toArray()[groupedRowsCount - 1];
706706
const groupRowElement = GridFunctions.getGroupedRows(fix)[groupedRowsCount - 1];
707-
groupRowElement.triggerEventHandler('click', null);
707+
groupRowElement.triggerEventHandler('pointerdown', null);
708708
fix.detectChanges();
709709

710710
GridFunctions.verifyGroupRowIsFocused(groupRow);
@@ -737,7 +737,7 @@ describe('IgxGrid - Keyboard navigation #grid', () => {
737737
expect(grid.groupsRowList.last.expanded).toBeTruthy();
738738

739739
const groupRowIndex = grid.groupsRowList.last.index;
740-
grid.groupsRowList.last.nativeElement.dispatchEvent(new Event('click'));
740+
grid.groupsRowList.last.nativeElement.dispatchEvent(new Event('pointerdown'));
741741
await wait();
742742
fix.detectChanges();
743743
UIInteractions.triggerEventHandlerKeyDown('arrowDown', gridContent);
@@ -762,7 +762,7 @@ describe('IgxGrid - Keyboard navigation #grid', () => {
762762
fix.detectChanges();
763763

764764
let row = grid.getRowByIndex(1);
765-
row.nativeElement.dispatchEvent(new Event('click'));
765+
row.nativeElement.dispatchEvent(new Event('pointerdown'));
766766
await wait();
767767
fix.detectChanges();
768768

@@ -916,7 +916,7 @@ describe('IgxGrid - Keyboard navigation #grid', () => {
916916
await wait(DEBOUNCETIME);
917917
fix.detectChanges();
918918

919-
grid.navigateTo(9, -1, (args) => { args.target.nativeElement.click(); });
919+
grid.navigateTo(9, -1, (args) => { args.target.nativeElement.dispatchEvent(new Event('pointerdown')); });
920920
await wait(100);
921921
fix.detectChanges();
922922
await wait(100);

projects/igniteui-angular/src/lib/grids/grid/groupby-row.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class IgxGridGroupByRowComponent {
160160
}
161161

162162

163-
@HostListener('click')
163+
@HostListener('pointerdown')
164164
public activate() {
165165
this.grid.navigation.activeNode ? this.grid.navigation.activeNode.row = this.index :
166166
this.grid.navigation.activeNode = {row: this.index};

0 commit comments

Comments
 (0)