Skip to content

Commit ef853a0

Browse files
authored
Merge branch '9.0.x' into dkamburov/fix-7483-9.0.x
2 parents 388d333 + e20a9ed commit ef853a0

File tree

6 files changed

+63
-23
lines changed

6 files changed

+63
-23
lines changed

projects/igniteui-angular/src/lib/grids/api.service.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,6 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
540540
return false;
541541
}
542542

543-
public atInexistingPage(): boolean {
544-
return this.grid.totalPages - 1 > this.grid.page;
545-
}
546-
547543
public get_row_expansion_state(record: any): boolean {
548544
const grid = this.grid;
549545
const states = grid.expansionStates;

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

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
Directive
2929
} from '@angular/core';
3030
import ResizeObserver from 'resize-observer-polyfill';
31-
import { Subject, combineLatest, pipe } from 'rxjs';
31+
import { Subject, pipe } from 'rxjs';
3232
import { takeUntil, first, filter, throttleTime, map } from 'rxjs/operators';
3333
import { cloneArray, isEdge, isNavigationKey, flatten, mergeObjects, isIE } from '../core/utils';
3434
import { DataType } from '../data-operations/data-util';
@@ -2639,12 +2639,6 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
26392639
this.summaryService.clearSummaryCache();
26402640
this._pipeTrigger++;
26412641
this.notifyChanges();
2642-
if (this.transactions.getAggregatedChanges(false).length === 0) {
2643-
// Needs better check, calling 'transactions.clear()' will also trigger this
2644-
if (this.gridAPI.atInexistingPage()) {
2645-
this.page--;
2646-
}
2647-
}
26482642
});
26492643

26502644
this.resizeNotify.pipe(destructor, filter(() => !this._init), throttleTime(100))
@@ -2821,6 +2815,15 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
28212815
this.setupColumns();
28222816
}
28232817

2818+
/**
2819+
* @hidden
2820+
* @internal
2821+
*/
2822+
public setFilteredSortedData(data) {
2823+
this._filteredSortedData = data;
2824+
this.refreshSearch(true, false);
2825+
}
2826+
28242827
/**
28252828
* @hidden @internal
28262829
*/
@@ -4024,7 +4027,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
40244027
* ```
40254028
* @param updateActiveInfo
40264029
*/
4027-
public refreshSearch(updateActiveInfo?: boolean): number {
4030+
public refreshSearch(updateActiveInfo?: boolean, endEdit = true): number {
40284031
if (this.lastSearchInfo.searchText) {
40294032
this.rebuildMatchCache();
40304033

@@ -4039,7 +4042,12 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
40394042
});
40404043
}
40414044

4042-
return this.find(this.lastSearchInfo.searchText, 0, this.lastSearchInfo.caseSensitive, this.lastSearchInfo.exactMatch, false);
4045+
return this.find(this.lastSearchInfo.searchText,
4046+
0,
4047+
this.lastSearchInfo.caseSensitive,
4048+
this.lastSearchInfo.exactMatch,
4049+
false,
4050+
endEdit);
40434051
} else {
40444052
return 0;
40454053
}
@@ -5356,12 +5364,14 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
53565364
return col.field + col._calcWidth;
53575365
}
53585366

5359-
private find(text: string, increment: number, caseSensitive?: boolean, exactMatch?: boolean, scroll?: boolean) {
5367+
private find(text: string, increment: number, caseSensitive?: boolean, exactMatch?: boolean, scroll?: boolean, endEdit = true) {
53605368
if (!this.rowList) {
53615369
return 0;
53625370
}
53635371

5364-
this.endEdit(false);
5372+
if (endEdit) {
5373+
this.endEdit(false);
5374+
}
53655375

53665376
if (!text) {
53675377
this.clearSearch();
@@ -5437,10 +5447,6 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
54375447
get filteredSortedData(): any[] {
54385448
return this._filteredSortedData;
54395449
}
5440-
set filteredSortedData(value: any[]) {
5441-
this._filteredSortedData = value;
5442-
this.refreshSearch(true);
5443-
}
54445450

54455451
/**
54465452
* @hidden

projects/igniteui-angular/src/lib/grids/grid/grid.pipes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class IgxGridSortingPipe implements PipeTransform {
3838
} else {
3939
result = DataUtil.sort(cloneArray(collection), expressions, sorting);
4040
}
41-
grid.filteredSortedData = result;
41+
grid.setFilteredSortedData(result);
4242

4343
return result;
4444
}

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

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { IForOfState } from '../../directives/for-of/for_of.directive';
99
import { IgxStringFilteringOperand } from '../../data-operations/filtering-condition';
1010
import { DefaultSortingStrategy } from '../../data-operations/sorting-strategy';
1111
import { configureTestSuite } from '../../test-utils/configure-suite';
12-
import { wait } from '../../test-utils/ui-interactions.spec';
12+
import { wait, UIInteractions } from '../../test-utils/ui-interactions.spec';
1313
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
1414
import { DataType } from '../../data-operations/data-util';
1515
import { setupGridScrollDetection } from '../../test-utils/helper-utils.spec';
@@ -686,6 +686,44 @@ describe('IgxGrid - search API #grid - ', () => {
686686
expect(highlights.length).toBe(1);
687687
expect(row.inEditMode).toBe(false);
688688
});
689+
690+
it('Should keep edit mode when tabbing, after search is applied', () => {
691+
grid.primaryKey = 'ID';
692+
grid.getColumnByName('Name').editable = true;
693+
grid.getColumnByName('JobTitle').editable = true;
694+
fix.detectChanges();
695+
const cell = grid.getCellByColumn(1, 'Name');
696+
const caseyCell = grid.getCellByColumn(0, 'Name');
697+
const newVal = 'newCellValue';
698+
699+
grid.findNext('Casey');
700+
fix.detectChanges();
701+
let highlights = caseyCell.nativeElement.querySelectorAll(HIGHLIGHT_CSS_CLASS);
702+
expect(highlights.length).toBe(1);
703+
704+
cell.nativeElement.dispatchEvent(new MouseEvent('dblclick'));
705+
fix.detectChanges();
706+
707+
expect(cell.editMode).toBeTruthy();
708+
highlights = caseyCell.nativeElement.querySelectorAll(HIGHLIGHT_CSS_CLASS);
709+
expect(highlights.length).toBe(1);
710+
711+
let cellInput = null;
712+
cellInput = cell.nativeElement.querySelector('[igxinput]');
713+
UIInteractions.setInputElementValue(cellInput, newVal);
714+
715+
// press tab on edited cell
716+
UIInteractions.triggerKeyDownEvtUponElem('tab', cell.nativeElement, true);
717+
fix.detectChanges();
718+
719+
expect(cell.value).toBe(newVal);
720+
expect(cell.editMode).toBeFalsy();
721+
highlights = caseyCell.nativeElement.querySelectorAll(HIGHLIGHT_CSS_CLASS);
722+
723+
const nextCell = grid.getCellByColumn(1, 'JobTitle');
724+
expect(nextCell.editMode).toBeTruthy();
725+
expect(highlights.length).toBe(1);
726+
});
689727
});
690728

691729
describe('ScrollableGrid - ', () => {

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.pipes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export class IgxTreeGridSortingPipe implements PipeTransform {
213213
}
214214
const filteredSortedData = [];
215215
this.flattenTreeGridRecords(result, filteredSortedData);
216-
grid.filteredSortedData = filteredSortedData;
216+
grid.setFilteredSortedData(filteredSortedData);
217217

218218
return result;
219219
}

src/app/grid-row-edit/grid-row-edit-sample.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ <h4>Cancel Grid Edit Events</h4>
9191
</div>
9292
<app-grid-with-transactions>
9393
<igx-grid #gridRowEditTransaction [data]="data" [primaryKey]="'ProductID'" width="900px" height="700px"
94-
[rowEditable]="true" [paging]="true" [perPage]="10" (onRowEdit)="rowEditDone($event)"
94+
[rowEditable]="true" [paging]="true" [perPage]="5" (onRowEdit)="rowEditDone($event)"
9595
(onRowEditCancel)="rowEditCancel($event)" (onRowEditEnter)="rowEditEnter($event)"
9696
(onCellEditEnter)="cellEnterEditMode($event)" (onCellEdit)="cellEditDone($event)"
9797
(onCellEditCancel)="cellEditCancel($event)">

0 commit comments

Comments
 (0)