Skip to content

Commit c3aad04

Browse files
committed
Merge branch 'rkaraivanov/skip-small-scrolls-logic' of https://github.com/IgniteUI/igniteui-angular into rkaraivanov/skip-small-scrolls-logic
2 parents 5662bbc + 2ad75f8 commit c3aad04

File tree

5 files changed

+28
-32
lines changed

5 files changed

+28
-32
lines changed

projects/igniteui-angular/src/lib/combo/combo.component.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,19 +1216,21 @@ describe('igxCombo', () => {
12161216
fixture.detectChanges();
12171217
let items = fixture.debugElement.queryAll(By.css(`.${CSS_CLASS_DROPDOWNLISTITEM}`));
12181218
let lastItem = items[items.length - 1].componentInstance;
1219+
let lastItemIndex = lastItem.index;
12191220
expect(lastItem).toBeDefined();
12201221
lastItem.clicked(mockClick);
12211222
await wait(30);
12221223
fixture.detectChanges();
1223-
expect(dropdown.focusedItem).toEqual(lastItem);
1224+
expect(dropdown.focusedItem.index).toEqual(lastItemIndex);
12241225
dropdown.navigateItem(-1);
12251226
await wait(30);
12261227
fixture.detectChanges();
12271228
expect(virtualMockDOWN).toHaveBeenCalledTimes(0);
1229+
lastItemIndex = lastItem.index;
12281230
lastItem.clicked(mockClick);
12291231
await wait(30);
12301232
fixture.detectChanges();
1231-
expect(dropdown.focusedItem).toEqual(lastItem);
1233+
expect(dropdown.focusedItem.index).toEqual(lastItemIndex);
12321234
dropdown.navigateNext();
12331235
await wait(30);
12341236
fixture.detectChanges();

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ export class IgxFilteringService implements OnDestroy {
105105
this._overlayService.onClosed.pipe(
106106
filter(overlay => overlay.id === this._componentOverlayId),
107107
takeUntil(this.destroy$)).subscribe(() => {
108-
console.log('Close');
109108
this._componentOverlayId = null;
110109
this.grid.theadRow.nativeElement.focus();
111110
});

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

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
ColumnEditablePropertyTestComponent
1414
} from '../../test-utils/grid-samples.spec';
1515
import { DebugElement } from '@angular/core';
16+
import { setupGridScrollDetection } from '../../test-utils/helper-utils.spec';
1617

1718
const DEBOUNCETIME = 30;
1819
const CELL_CSS_CLASS = '.igx-grid__td';
@@ -381,38 +382,31 @@ describe('IgxGrid - Cell Editing #grid', () => {
381382
});
382383

383384
it('When cell in editMode and try to navigate with `ArrowUp` - focus should remain over the input.', (async () => {
384-
const verticalScroll = grid.verticalScrollContainer.getScroll();
385-
let expectedScroll;
386-
let cellElem;
387-
GridFunctions.scrollTop(grid, 1000);
388-
await wait(500);
385+
let cell = grid.getCellByColumn(0, 'firstName' );
386+
UIInteractions.simulateClickAndSelectEvent(cell);
387+
fixture.detectChanges();
388+
GridFunctions.simulateGridContentKeydown(fixture, 'ArrowDown', false, false, true);
389+
await wait(100);
389390
fixture.detectChanges();
390391

391-
let testCells = grid.getColumnByName('firstName').cells;
392-
let cell = testCells[testCells.length - 1];
393-
cellElem = cell.nativeElement;
394-
395-
cellElem.dispatchEvent(new Event('focus'));
396-
cellElem.dispatchEvent(new MouseEvent('dblclick'));
392+
cell = grid.getCellByColumn(8, 'firstName' );
393+
UIInteractions.simulateDoubleClickAndSelectEvent(cell);
394+
await wait(DEBOUNCETIME);
397395
fixture.detectChanges();
398-
await wait(50);
399396

400-
let inputElem: HTMLInputElement = document.activeElement as HTMLInputElement;
397+
const inputElem: HTMLInputElement = document.activeElement as HTMLInputElement;
401398
expect(cell.editMode).toBeTruthy();
402-
expect(cellElem.classList.contains(CELL_CLASS_IN_EDIT_MODE)).toBe(true);
403-
expectedScroll = verticalScroll.scrollTop;
399+
expect(cell.nativeElement.classList.contains(CELL_CLASS_IN_EDIT_MODE)).toBe(true);
400+
const expectedScroll = grid.verticalScrollContainer.getScroll().scrollTop;
404401

405402
UIInteractions.triggerKeyDownEvtUponElem('ArrowUp', inputElem, true);
406-
fixture.detectChanges();
407403
await wait(DEBOUNCETIME);
404+
fixture.detectChanges();
408405

409-
inputElem = document.activeElement as HTMLInputElement;
410-
testCells = grid.getColumnByName('firstName').cells;
411-
cell = testCells[testCells.length - 1];
412-
cellElem = cell.nativeElement;
406+
cell = grid.getCellByColumn(8, 'firstName' );
413407
expect(cell.editMode).toBeTruthy();
414-
expect(cellElem.classList.contains(CELL_CLASS_IN_EDIT_MODE)).toBe(true);
415-
expect(verticalScroll.scrollTop).toBe(expectedScroll);
408+
expect(cell.nativeElement.classList.contains(CELL_CLASS_IN_EDIT_MODE)).toBe(true);
409+
expect(grid.verticalScrollContainer.getScroll().scrollTop).toBe(expectedScroll);
416410
}));
417411

418412
it('When cell in editMode and try to navigate with `ArrowRight` - focus should remain over the input.', (async () => {

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ describe('IgxTreeGrid - Multi Cell selection #tGrid', () => {
369369
const selectionChangeSpy = spyOn<any>(treeGrid.onRangeSelection, 'emit').and.callThrough();
370370
treeGrid.getColumnByName('Name').hasSummary = true;
371371
treeGrid.summaryCalculationMode = 'childLevelsOnly';
372+
await wait(30);
372373
fix.detectChanges();
373374

374375
const gridContent = GridFunctions.getGridContent(fix);
@@ -378,28 +379,28 @@ describe('IgxTreeGrid - Multi Cell selection #tGrid', () => {
378379

379380
GridSelectionFunctions.verifyCellSelected(cell);
380381

381-
for (let i = 8; i < 16; i++) {
382+
for (let i = 8; i < 12; i++) {
382383
UIInteractions.triggerEventHandlerKeyDown('arrowdown', gridContent, false, true);
383384
await wait(30);
384385
fix.detectChanges();
385386
}
386387

387-
expect(selectionChangeSpy).toHaveBeenCalledTimes(5);
388-
GridSelectionFunctions.verifyCellsRegionSelected(treeGrid, 8, 15, 1, 1);
388+
expect(selectionChangeSpy).toHaveBeenCalledTimes(3);
389+
GridSelectionFunctions.verifyCellsRegionSelected(treeGrid, 8, 11, 1, 1);
389390

390391
for (let i = 1; i < 3; i++) {
391392
UIInteractions.triggerEventHandlerKeyDown('arrowright', gridContent, false, true);
392393
await wait(30);
393394
fix.detectChanges();
394395
}
395396

396-
GridSelectionFunctions.verifyCellsRegionSelected(treeGrid, 8, 15, 1, 1);
397+
GridSelectionFunctions.verifyCellsRegionSelected(treeGrid, 8, 11, 1, 1);
397398

398399
UIInteractions.triggerEventHandlerKeyDown('arrowup', gridContent, false, true);
399400
await wait(30);
400401
fix.detectChanges();
401-
expect(selectionChangeSpy).toHaveBeenCalledTimes(6);
402-
GridSelectionFunctions.verifySelectedRange(treeGrid, 8, 15, 1, 3);
402+
expect(selectionChangeSpy).toHaveBeenCalledTimes(4);
403+
GridSelectionFunctions.verifySelectedRange(treeGrid, 8, 11, 1, 3);
403404
}));
404405

405406
it('Summaries: should clear selected range when navigate from summary cell without pressed shift', (async () => {

projects/igniteui-angular/src/lib/test-utils/grid-functions.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export class GridFunctions {
244244
}
245245

246246
public static getGroupedRows(fix): DebugElement[] {
247-
return fix.debugElement.queryAll(By.css(GROUP_ROW_CLASS));
247+
return this.sortDebugElementsVertically(fix.debugElement.queryAll(By.css(GROUP_ROW_CLASS)));
248248
}
249249

250250
public static verifyGroupRowIsFocused(groupRow, focused = true) {

0 commit comments

Comments
 (0)