Skip to content

Commit e5472f4

Browse files
Merge branch '17.2.x' into bpachilova/comboArrayValueKey-14103-17.2.x
2 parents 5c96fdd + bec9363 commit e5472f4

File tree

8 files changed

+99
-41
lines changed

8 files changed

+99
-41
lines changed

projects/igniteui-angular/src/lib/calendar/month-picker/month-picker.component.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,35 @@ describe('IgxMonthPicker', () => {
525525
expect(monthPicker.activeViewChanged.emit).toHaveBeenCalled();
526526
expect(monthPicker.activeView).toEqual('year');
527527
});
528+
529+
it('should emit viewDateChanged event when changing year with arrow buttons', () => {
530+
const fixture = TestBed.createComponent(IgxMonthPickerSampleComponent);
531+
const monthPicker = fixture.componentInstance.monthPicker;
532+
spyOn(monthPicker.viewDateChanged, 'emit');
533+
534+
fixture.detectChanges();
535+
536+
const dom = fixture.debugElement;
537+
const prev = dom.query(By.css('.igx-calendar-picker__prev'));
538+
const next = dom.query(By.css('.igx-calendar-picker__next'));
539+
540+
UIInteractions.simulateMouseDownEvent(prev.nativeElement);
541+
fixture.detectChanges();
542+
543+
expect(monthPicker.viewDateChanged.emit).toHaveBeenCalledWith({
544+
previousValue: new Date(2019, 1, 1),
545+
currentValue: new Date(2018, 1, 1)
546+
});
547+
548+
UIInteractions.simulateMouseDownEvent(next.nativeElement);
549+
UIInteractions.simulateMouseDownEvent(next.nativeElement);
550+
fixture.detectChanges();
551+
552+
expect(monthPicker.viewDateChanged.emit).toHaveBeenCalledWith({
553+
previousValue: new Date(2018, 1, 1),
554+
currentValue: new Date(2019, 1, 1)
555+
});
556+
});
528557
});
529558

530559
@Component({

projects/igniteui-angular/src/lib/calendar/month-picker/month-picker.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ export class IgxMonthPickerComponent extends IgxCalendarBaseDirective implements
117117
if (this.isDecadeView) {
118118
this.viewDate = CalendarDay.from(this.viewDate).add('year', -15).native;
119119
}
120+
121+
this.viewDateChanged.emit({
122+
previousValue: this.previousViewDate,
123+
currentValue: this.viewDate,
124+
});
120125
}
121126

122127
/**
@@ -134,6 +139,11 @@ export class IgxMonthPickerComponent extends IgxCalendarBaseDirective implements
134139
if (this.isDecadeView) {
135140
this.viewDate = CalendarDay.from(this.viewDate).add('year', 15).native;
136141
}
142+
143+
this.viewDateChanged.emit({
144+
previousValue: this.previousViewDate,
145+
currentValue: this.viewDate,
146+
});
137147
}
138148

139149
/**

projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ export class IgxGridForOfDirective<T, U extends T[] = T[]> extends IgxForOfDirec
16211621
}
16221622
if (this.igxForScrollOrientation === 'horizontal') {
16231623
// in case collection has changes, reset sync service
1624-
this.syncService.setMaster(this, true);
1624+
this.syncService.setMaster(this, this.igxGridForOfUniqueSizeCache);
16251625
}
16261626
}
16271627
const defaultItemSize = 'igxForItemSize';

projects/igniteui-angular/src/lib/directives/for-of/for_of.sync.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ export class IgxForOfSyncService {
2121
*/
2222
public setMaster(directive: IgxGridForOfDirective<any, any[]>, forced = false) {
2323
const orientation = directive.igxForScrollOrientation;
24+
// in case master is not in dom, set a new master
25+
const isMasterInDom = this._master.get(orientation)?.dc?.instance?._viewContainer.element.nativeElement.isConnected;
26+
if (!isMasterInDom) {
27+
forced = true;
28+
}
2429
if (orientation && (forced || !this._master.has(orientation))) {
2530
this._master.set(orientation, directive);
2631
}

projects/igniteui-angular/src/lib/grids/common/grid.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ export interface GridType extends IGridDataBindable {
933933
/** Represents the last search in the grid
934934
* It contains the search text (the user has entered), the match and some settings for the search
935935
*/
936-
lastSearchInfo: ISearchInfo;
936+
readonly lastSearchInfo: ISearchInfo;
937937
/** @hidden @internal */
938938
page: number;
939939
/** @hidden @internal */

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

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,15 +2864,9 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
28642864
/**
28652865
* Represents the last search information.
28662866
*/
2867-
public lastSearchInfo: ISearchInfo = {
2868-
searchText: '',
2869-
caseSensitive: false,
2870-
exactMatch: false,
2871-
activeMatchIndex: 0,
2872-
matchInfoCache: [],
2873-
matchCount: 0,
2874-
content: ''
2875-
};
2867+
public get lastSearchInfo(): ISearchInfo {
2868+
return this._lastSearchInfo;
2869+
}
28762870

28772871
/**
28782872
* @hidden @internal
@@ -3040,6 +3034,15 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
30403034
protected _filterStrategy: IFilteringStrategy = new FilteringStrategy();
30413035
protected _autoGeneratedCols = [];
30423036
protected _dataView = [];
3037+
protected _lastSearchInfo: ISearchInfo = {
3038+
searchText: '',
3039+
caseSensitive: false,
3040+
exactMatch: false,
3041+
activeMatchIndex: 0,
3042+
matchInfoCache: [],
3043+
matchCount: 0,
3044+
content: ''
3045+
};
30433046

30443047
/** @hidden @internal */
30453048
public get paginator() {
@@ -5089,25 +5092,25 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
50895092
* @param updateActiveInfo
50905093
*/
50915094
public refreshSearch(updateActiveInfo?: boolean, endEdit = true): number {
5092-
if (this.lastSearchInfo.searchText) {
5095+
if (this._lastSearchInfo.searchText) {
50935096
this.rebuildMatchCache();
50945097

50955098
if (updateActiveInfo) {
50965099
const activeInfo = this.textHighlightService.highlightGroupsMap.get(this.id);
5097-
this.lastSearchInfo.matchInfoCache.forEach((match, i) => {
5100+
this._lastSearchInfo.matchInfoCache.forEach((match, i) => {
50985101
if (match.column === activeInfo.column &&
50995102
match.row === activeInfo.row &&
51005103
match.index === activeInfo.index &&
51015104
compareMaps(match.metadata, activeInfo.metadata)) {
5102-
this.lastSearchInfo.activeMatchIndex = i;
5105+
this._lastSearchInfo.activeMatchIndex = i;
51035106
}
51045107
});
51055108
}
51065109

5107-
return this.find(this.lastSearchInfo.searchText,
5110+
return this.find(this._lastSearchInfo.searchText,
51085111
0,
5109-
this.lastSearchInfo.caseSensitive,
5110-
this.lastSearchInfo.exactMatch,
5112+
this._lastSearchInfo.caseSensitive,
5113+
this._lastSearchInfo.exactMatch,
51115114
false,
51125115
endEdit);
51135116
} else {
@@ -5124,7 +5127,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
51245127
* ```
51255128
*/
51265129
public clearSearch() {
5127-
this.lastSearchInfo = {
5130+
this._lastSearchInfo = {
51285131
searchText: '',
51295132
caseSensitive: false,
51305133
exactMatch: false,
@@ -7509,10 +7512,10 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
75097512
const exactMatchResolved = exactMatch ? true : false;
75107513
let rebuildCache = false;
75117514

7512-
if (this.lastSearchInfo.searchText !== text ||
7513-
this.lastSearchInfo.caseSensitive !== caseSensitiveResolved ||
7514-
this.lastSearchInfo.exactMatch !== exactMatchResolved) {
7515-
this.lastSearchInfo = {
7515+
if (this._lastSearchInfo.searchText !== text ||
7516+
this._lastSearchInfo.caseSensitive !== caseSensitiveResolved ||
7517+
this._lastSearchInfo.exactMatch !== exactMatchResolved) {
7518+
this._lastSearchInfo = {
75167519
searchText: text,
75177520
activeMatchIndex: 0,
75187521
caseSensitive: caseSensitiveResolved,
@@ -7524,7 +7527,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
75247527

75257528
rebuildCache = true;
75267529
} else {
7527-
this.lastSearchInfo.activeMatchIndex += increment;
7530+
this._lastSearchInfo.activeMatchIndex += increment;
75287531
}
75297532

75307533
if (rebuildCache) {
@@ -7539,15 +7542,15 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
75397542
this.rebuildMatchCache();
75407543
}
75417544

7542-
if (this.lastSearchInfo.activeMatchIndex >= this.lastSearchInfo.matchCount) {
7543-
this.lastSearchInfo.activeMatchIndex = 0;
7544-
} else if (this.lastSearchInfo.activeMatchIndex < 0) {
7545-
this.lastSearchInfo.activeMatchIndex = this.lastSearchInfo.matchCount - 1;
7545+
if (this._lastSearchInfo.activeMatchIndex >= this._lastSearchInfo.matchCount) {
7546+
this._lastSearchInfo.activeMatchIndex = 0;
7547+
} else if (this._lastSearchInfo.activeMatchIndex < 0) {
7548+
this._lastSearchInfo.activeMatchIndex = this._lastSearchInfo.matchCount - 1;
75467549
}
75477550

7548-
if (this.lastSearchInfo.matchCount > 0) {
7549-
const matchInfo = this.lastSearchInfo.matchInfoCache[this.lastSearchInfo.activeMatchIndex];
7550-
this.lastSearchInfo = { ...this.lastSearchInfo };
7551+
if (this._lastSearchInfo.matchCount > 0) {
7552+
const matchInfo = this._lastSearchInfo.matchInfoCache[this._lastSearchInfo.activeMatchIndex];
7553+
this._lastSearchInfo = { ...this._lastSearchInfo };
75517554

75527555
if (scroll !== false) {
75537556
this.scrollTo(matchInfo.row, matchInfo.column);
@@ -7564,15 +7567,15 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
75647567
this.textHighlightService.clearActiveHighlight(this.id);
75657568
}
75667569

7567-
return this.lastSearchInfo.matchCount;
7570+
return this._lastSearchInfo.matchCount;
75687571
}
75697572

75707573
private rebuildMatchCache() {
7571-
this.lastSearchInfo.matchInfoCache = [];
7574+
this._lastSearchInfo.matchInfoCache = [];
75727575

7573-
const caseSensitive = this.lastSearchInfo.caseSensitive;
7574-
const exactMatch = this.lastSearchInfo.exactMatch;
7575-
const searchText = caseSensitive ? this.lastSearchInfo.searchText : this.lastSearchInfo.searchText.toLowerCase();
7576+
const caseSensitive = this._lastSearchInfo.caseSensitive;
7577+
const exactMatch = this._lastSearchInfo.exactMatch;
7578+
const searchText = caseSensitive ? this._lastSearchInfo.searchText : this._lastSearchInfo.searchText.toLowerCase();
75767579
const data = this.filteredSortedData;
75777580
const columnItems = this.visibleColumns.filter((c) => !c.columnGroup).sort((c1, c2) => c1.visibleIndex - c2.visibleIndex);
75787581

@@ -7596,7 +7599,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
75967599
metadata: new Map<string, boolean>([['pinned', this.isRecordPinnedByIndex(rowIndex)]])
75977600
};
75987601

7599-
this.lastSearchInfo.matchInfoCache.push(mic);
7602+
this._lastSearchInfo.matchInfoCache.push(mic);
76007603
}
76017604
} else {
76027605
let occurrenceIndex = 0;
@@ -7610,7 +7613,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
76107613
metadata: new Map<string, boolean>([['pinned', this.isRecordPinnedByIndex(rowIndex)]])
76117614
};
76127615

7613-
this.lastSearchInfo.matchInfoCache.push(mic);
7616+
this._lastSearchInfo.matchInfoCache.push(mic);
76147617

76157618
searchValue = searchValue.substring(searchIndex + searchText.length);
76167619
searchIndex = searchValue.indexOf(searchText);
@@ -7620,7 +7623,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
76207623
});
76217624
});
76227625

7623-
this.lastSearchInfo.matchCount = this.lastSearchInfo.matchInfoCache.length;
7626+
this._lastSearchInfo.matchCount = this._lastSearchInfo.matchInfoCache.length;
76247627
}
76257628

76267629
// TODO: About to Move to CRUD

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
11461146
const colLength = this.columns.length;
11471147
const topCols = this.columnList.filter((item) => colsArray.indexOf(item) === -1);
11481148
if (topCols.length > 0) {
1149-
this.updateColumns(topCols);
1149+
this.initColumns(topCols, (col: IgxColumnComponent) => this.columnInit.emit(col));
11501150
if (recalcColSizes && this.columns.length !== colLength) {
11511151
this.calculateGridSizes(false);
11521152
}

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,16 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
628628
expect(hierarchicalGrid.tbody.nativeElement.attributes['aria-activedescendant'].value).toEqual(hierarchicalGrid.id);
629629
expect(childGrid.tbody.nativeElement.attributes['aria-activedescendant'].value).toEqual(`${childGrid.id}_0_1`);
630630
});
631+
632+
it('should emit columnInit when a column is added runtime.', async() => {
633+
spyOn(hierarchicalGrid.columnInit, 'emit').and.callThrough();
634+
fixture.detectChanges();
635+
fixture.componentInstance.showAnotherCol = true;
636+
fixture.detectChanges();
637+
await wait(30);
638+
fixture.detectChanges();
639+
expect(hierarchicalGrid.columnInit.emit).toHaveBeenCalled();
640+
});
631641
});
632642

633643
describe('IgxHierarchicalGrid Row Islands #hGrid', () => {
@@ -1827,6 +1837,7 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
18271837
<igx-hierarchical-grid #grid1 [data]="data"
18281838
[autoGenerate]="false" [height]="'400px'" [width]="width" #hierarchicalGrid>
18291839
<igx-column field="ID"></igx-column>
1840+
<igx-column field="AnotherColumn" *ngIf="showAnotherCol"></igx-column>
18301841
<igx-column field="ProductName"></igx-column>
18311842
<igx-row-island [key]="'childData'" [autoGenerate]="false" #rowIsland>
18321843
<igx-column field="ID"></igx-column>
@@ -1839,15 +1850,15 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
18391850
</igx-row-island>
18401851
</igx-hierarchical-grid>`,
18411852
standalone: true,
1842-
imports: [IgxHierarchicalGridComponent, IgxColumnComponent, IgxRowIslandComponent]
1853+
imports: [IgxHierarchicalGridComponent, IgxColumnComponent, IgxRowIslandComponent, NgIf]
18431854
})
18441855
export class IgxHierarchicalGridTestBaseComponent {
18451856
@ViewChild('hierarchicalGrid', { read: IgxHierarchicalGridComponent, static: true }) public hgrid: IgxHierarchicalGridComponent;
18461857
@ViewChild('rowIsland', { read: IgxRowIslandComponent, static: true }) public rowIsland: IgxRowIslandComponent;
18471858
@ViewChild('rowIsland2', { read: IgxRowIslandComponent, static: true }) public rowIsland2: IgxRowIslandComponent;
18481859
public data;
18491860
public width = '500px';
1850-
1861+
public showAnotherCol = false;
18511862
constructor() {
18521863
// 3 level hierarchy
18531864
this.data = this.generateDataUneven(20, 3);

0 commit comments

Comments
 (0)