Skip to content

Commit 19d1eb8

Browse files
Merge branch '18.0.x' into bpachilova/comboArrayValueKey-14103-18.0.x
2 parents 3a1937c + 30e5735 commit 19d1eb8

File tree

9 files changed

+100
-42
lines changed

9 files changed

+100
-42
lines changed

projects/igniteui-angular/migrations/update-18_0_0/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export default (): Rule => async (host: Tree, context: SchematicContext) => {
9292
return s;
9393
}
9494
// ref - https://angular.dev/reference/configs/workspace-config#styles-and-scripts-configuration
95-
if (s instanceof Object && 'input' in s) {
95+
if (typeof s === "object" && 'input' in s) {
9696
return s.input as string;
9797
}
9898
})

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
@@ -1626,7 +1626,7 @@ export class IgxGridForOfDirective<T, U extends T[] = T[]> extends IgxForOfDirec
16261626
}
16271627
if (this.igxForScrollOrientation === 'horizontal') {
16281628
// in case collection has changes, reset sync service
1629-
this.syncService.setMaster(this, true);
1629+
this.syncService.setMaster(this, this.igxGridForOfUniqueSizeCache);
16301630
}
16311631
}
16321632
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
@@ -930,7 +930,7 @@ export interface GridType extends IGridDataBindable {
930930
/** Represents the last search in the grid
931931
* It contains the search text (the user has entered), the match and some settings for the search
932932
*/
933-
lastSearchInfo: ISearchInfo;
933+
readonly lastSearchInfo: ISearchInfo;
934934
/** @hidden @internal */
935935
page: number;
936936
/** @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 implements GridType,
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 implements GridType,
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
protected gridComputedStyles;
30443047

30453048
/** @hidden @internal */
@@ -5097,25 +5100,25 @@ export abstract class IgxGridBaseDirective implements GridType,
50975100
* @param updateActiveInfo
50985101
*/
50995102
public refreshSearch(updateActiveInfo?: boolean, endEdit = true): number {
5100-
if (this.lastSearchInfo.searchText) {
5103+
if (this._lastSearchInfo.searchText) {
51015104
this.rebuildMatchCache();
51025105

51035106
if (updateActiveInfo) {
51045107
const activeInfo = this.textHighlightService.highlightGroupsMap.get(this.id);
5105-
this.lastSearchInfo.matchInfoCache.forEach((match, i) => {
5108+
this._lastSearchInfo.matchInfoCache.forEach((match, i) => {
51065109
if (match.column === activeInfo.column &&
51075110
match.row === activeInfo.row &&
51085111
match.index === activeInfo.index &&
51095112
compareMaps(match.metadata, activeInfo.metadata)) {
5110-
this.lastSearchInfo.activeMatchIndex = i;
5113+
this._lastSearchInfo.activeMatchIndex = i;
51115114
}
51125115
});
51135116
}
51145117

5115-
return this.find(this.lastSearchInfo.searchText,
5118+
return this.find(this._lastSearchInfo.searchText,
51165119
0,
5117-
this.lastSearchInfo.caseSensitive,
5118-
this.lastSearchInfo.exactMatch,
5120+
this._lastSearchInfo.caseSensitive,
5121+
this._lastSearchInfo.exactMatch,
51195122
false,
51205123
endEdit);
51215124
} else {
@@ -5132,7 +5135,7 @@ export abstract class IgxGridBaseDirective implements GridType,
51325135
* ```
51335136
*/
51345137
public clearSearch() {
5135-
this.lastSearchInfo = {
5138+
this._lastSearchInfo = {
51365139
searchText: '',
51375140
caseSensitive: false,
51385141
exactMatch: false,
@@ -7524,10 +7527,10 @@ export abstract class IgxGridBaseDirective implements GridType,
75247527
const exactMatchResolved = exactMatch ? true : false;
75257528
let rebuildCache = false;
75267529

7527-
if (this.lastSearchInfo.searchText !== text ||
7528-
this.lastSearchInfo.caseSensitive !== caseSensitiveResolved ||
7529-
this.lastSearchInfo.exactMatch !== exactMatchResolved) {
7530-
this.lastSearchInfo = {
7530+
if (this._lastSearchInfo.searchText !== text ||
7531+
this._lastSearchInfo.caseSensitive !== caseSensitiveResolved ||
7532+
this._lastSearchInfo.exactMatch !== exactMatchResolved) {
7533+
this._lastSearchInfo = {
75317534
searchText: text,
75327535
activeMatchIndex: 0,
75337536
caseSensitive: caseSensitiveResolved,
@@ -7539,7 +7542,7 @@ export abstract class IgxGridBaseDirective implements GridType,
75397542

75407543
rebuildCache = true;
75417544
} else {
7542-
this.lastSearchInfo.activeMatchIndex += increment;
7545+
this._lastSearchInfo.activeMatchIndex += increment;
75437546
}
75447547

75457548
if (rebuildCache) {
@@ -7554,15 +7557,15 @@ export abstract class IgxGridBaseDirective implements GridType,
75547557
this.rebuildMatchCache();
75557558
}
75567559

7557-
if (this.lastSearchInfo.activeMatchIndex >= this.lastSearchInfo.matchCount) {
7558-
this.lastSearchInfo.activeMatchIndex = 0;
7559-
} else if (this.lastSearchInfo.activeMatchIndex < 0) {
7560-
this.lastSearchInfo.activeMatchIndex = this.lastSearchInfo.matchCount - 1;
7560+
if (this._lastSearchInfo.activeMatchIndex >= this._lastSearchInfo.matchCount) {
7561+
this._lastSearchInfo.activeMatchIndex = 0;
7562+
} else if (this._lastSearchInfo.activeMatchIndex < 0) {
7563+
this._lastSearchInfo.activeMatchIndex = this._lastSearchInfo.matchCount - 1;
75617564
}
75627565

7563-
if (this.lastSearchInfo.matchCount > 0) {
7564-
const matchInfo = this.lastSearchInfo.matchInfoCache[this.lastSearchInfo.activeMatchIndex];
7565-
this.lastSearchInfo = { ...this.lastSearchInfo };
7566+
if (this._lastSearchInfo.matchCount > 0) {
7567+
const matchInfo = this._lastSearchInfo.matchInfoCache[this._lastSearchInfo.activeMatchIndex];
7568+
this._lastSearchInfo = { ...this._lastSearchInfo };
75667569

75677570
if (scroll !== false) {
75687571
this.scrollTo(matchInfo.row, matchInfo.column);
@@ -7579,15 +7582,15 @@ export abstract class IgxGridBaseDirective implements GridType,
75797582
this.textHighlightService.clearActiveHighlight(this.id);
75807583
}
75817584

7582-
return this.lastSearchInfo.matchCount;
7585+
return this._lastSearchInfo.matchCount;
75837586
}
75847587

75857588
private rebuildMatchCache() {
7586-
this.lastSearchInfo.matchInfoCache = [];
7589+
this._lastSearchInfo.matchInfoCache = [];
75877590

7588-
const caseSensitive = this.lastSearchInfo.caseSensitive;
7589-
const exactMatch = this.lastSearchInfo.exactMatch;
7590-
const searchText = caseSensitive ? this.lastSearchInfo.searchText : this.lastSearchInfo.searchText.toLowerCase();
7591+
const caseSensitive = this._lastSearchInfo.caseSensitive;
7592+
const exactMatch = this._lastSearchInfo.exactMatch;
7593+
const searchText = caseSensitive ? this._lastSearchInfo.searchText : this._lastSearchInfo.searchText.toLowerCase();
75917594
const data = this.filteredSortedData;
75927595
const columnItems = this.visibleColumns.filter((c) => !c.columnGroup).sort((c1, c2) => c1.visibleIndex - c2.visibleIndex);
75937596

@@ -7611,7 +7614,7 @@ export abstract class IgxGridBaseDirective implements GridType,
76117614
metadata: new Map<string, boolean>([['pinned', this.isRecordPinnedByIndex(rowIndex)]])
76127615
};
76137616

7614-
this.lastSearchInfo.matchInfoCache.push(mic);
7617+
this._lastSearchInfo.matchInfoCache.push(mic);
76157618
}
76167619
} else {
76177620
let occurrenceIndex = 0;
@@ -7625,7 +7628,7 @@ export abstract class IgxGridBaseDirective implements GridType,
76257628
metadata: new Map<string, boolean>([['pinned', this.isRecordPinnedByIndex(rowIndex)]])
76267629
};
76277630

7628-
this.lastSearchInfo.matchInfoCache.push(mic);
7631+
this._lastSearchInfo.matchInfoCache.push(mic);
76297632

76307633
searchValue = searchValue.substring(searchIndex + searchText.length);
76317634
searchIndex = searchValue.indexOf(searchText);
@@ -7635,7 +7638,7 @@ export abstract class IgxGridBaseDirective implements GridType,
76357638
});
76367639
});
76377640

7638-
this.lastSearchInfo.matchCount = this.lastSearchInfo.matchInfoCache.length;
7641+
this._lastSearchInfo.matchCount = this._lastSearchInfo.matchInfoCache.length;
76397642
}
76407643

76417644
private updateDefaultRowHeight() {

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
@@ -1138,7 +1138,7 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
11381138
const colLength = this.columns.length;
11391139
const topCols = this.columnList.filter((item) => colsArray.indexOf(item) === -1);
11401140
if (topCols.length > 0) {
1141-
this.updateColumns(topCols);
1141+
this.initColumns(topCols, (col: IgxColumnComponent) => this.columnInit.emit(col));
11421142
if (recalcColSizes && this.columns.length !== colLength) {
11431143
this.calculateGridSizes(false);
11441144
}

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)