Skip to content

Commit 56e818d

Browse files
Merge branch '18.0.x' of https://github.com/IgniteUI/igniteui-angular into ganastasov/fix-14187-18.0.x
2 parents f607936 + ddbabc8 commit 56e818d

File tree

15 files changed

+348
-61
lines changed

15 files changed

+348
-61
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ All notable changes for each version of this project will be documented in this
7676
### General
7777
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
7878
- The `contextMenu` event now fires when the end-user clicks to the right of the right-most cell in the grid in case the grid's columns don't span its full width. For this reason the event argument of the event is now of type `IGridContextMenuEventArgs` which contains the row object as well as the cell one. The latter will be `null` if the event didn't originate from a cell. **This is not a breaking change** as the new type extends the old.
79+
- `IgxSimpleCombo`
80+
- **Behavioral Change** The `selectionChanging` event will now trigger when typing the first character in the input if there is a previously selected value in the `IgxSimpleCombo`.
7981

8082
## 17.1.0
8183
### New Features

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/combo/combo.common.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { caseSensitive } from '@igniteui/material-icons-extended';
2828
import { noop, Subject } from 'rxjs';
2929
import { takeUntil } from 'rxjs/operators';
3030
import { IgxSelectionAPIService } from '../core/selection';
31-
import { CancelableBrowserEventArgs, cloneArray, IBaseCancelableBrowserEventArgs, IBaseEventArgs, isNaNvalue, rem } from '../core/utils';
31+
import { CancelableBrowserEventArgs, cloneArray, IBaseCancelableBrowserEventArgs, IBaseEventArgs, rem } from '../core/utils';
3232
import { SortingDirection } from '../data-operations/sorting-strategy';
3333
import { IForOfState, IgxForOfDirective } from '../directives/for-of/for_of.directive';
3434
import { IgxIconService } from '../icon/icon.service';
@@ -46,6 +46,7 @@ import { ComboResourceStringsEN, IComboResourceStrings } from '../core/i18n/comb
4646
import { getCurrentResourceStrings } from '../core/i18n/resources';
4747
import { DOCUMENT } from '@angular/common';
4848
import { Size } from '../grids/common/enums';
49+
import { isEqual } from 'lodash-es';
4950

5051
export const IGX_COMBO_COMPONENT = /*@__PURE__*/new InjectionToken<IgxComboBase>('IgxComboComponentToken');
5152

@@ -1288,9 +1289,7 @@ export abstract class IgxComboBaseDirective implements IgxComboBase, AfterViewCh
12881289
}
12891290

12901291
return keys.map(key => {
1291-
const item = isNaNvalue(key)
1292-
? this.data.find(entry => isNaNvalue(entry[this.valueKey]))
1293-
: this.data.find(entry => entry[this.valueKey] === key);
1292+
const item = this.data.find(entry => isEqual(entry[this.valueKey], key));
12941293

12951294
return item !== undefined ? item : { [this.valueKey]: key };
12961295
});

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

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,6 +2343,55 @@ describe('igxCombo', () => {
23432343
expect(combo.value).toEqual([]);
23442344
expect(combo.displayValue).toEqual('Selected Count: 0');
23452345
});
2346+
it('should handle selection for combo with array type value key correctly - issue #14103', () => {
2347+
fixture = TestBed.createComponent(ComboArrayTypeValueKeyComponent);
2348+
fixture.detectChanges();
2349+
combo = fixture.componentInstance.combo;
2350+
input = fixture.debugElement.query(By.css(`.${CSS_CLASS_COMBO_INPUTGROUP}`));
2351+
const items = fixture.componentInstance.items;
2352+
expect(combo).toBeDefined();
2353+
2354+
const selectionSpy = spyOn(combo.selectionChanging, 'emit');
2355+
let expectedResults: IComboSelectionChangingEventArgs = {
2356+
newValue: [combo.data[1][combo.valueKey]],
2357+
oldValue: [],
2358+
newSelection: [combo.data[1]],
2359+
oldSelection: [],
2360+
added: [combo.data[1]],
2361+
removed: [],
2362+
event: undefined,
2363+
owner: combo,
2364+
displayText: `${combo.data[1][combo.displayKey]}`,
2365+
cancel: false
2366+
};
2367+
2368+
let expectedDisplayText = items[1][combo.displayKey];
2369+
combo.select([fixture.componentInstance.items[1].value]);
2370+
fixture.detectChanges();
2371+
2372+
expect(selectionSpy).toHaveBeenCalledWith(expectedResults);
2373+
expect(input.nativeElement.value).toEqual(expectedDisplayText);
2374+
2375+
expectedDisplayText = `${items[1][combo.displayKey]}, ${items[2][combo.displayKey]}`;
2376+
expectedResults = {
2377+
newValue: [combo.data[1][combo.valueKey], combo.data[2][combo.valueKey]],
2378+
oldValue: [combo.data[1][combo.valueKey]],
2379+
newSelection: [combo.data[1], combo.data[2]],
2380+
oldSelection: [combo.data[1]],
2381+
added: [combo.data[2]],
2382+
removed: [],
2383+
event: undefined,
2384+
owner: combo,
2385+
displayText: expectedDisplayText,
2386+
cancel: false
2387+
};
2388+
2389+
combo.select([items[2].value]);
2390+
fixture.detectChanges();
2391+
2392+
expect(selectionSpy).toHaveBeenCalledWith(expectedResults);
2393+
expect(input.nativeElement.value).toEqual(expectedDisplayText);
2394+
});
23462395
});
23472396
describe('Grouping tests: ', () => {
23482397
beforeEach(() => {
@@ -3768,3 +3817,32 @@ export class IgxComboBindingDataAfterInitComponent implements AfterViewInit {
37683817
}, 1000);
37693818
}
37703819
}
3820+
3821+
@Component({
3822+
template: `
3823+
<igx-combo [data]="items" valueKey="value" displayKey="item"></igx-combo>`,
3824+
standalone: true,
3825+
imports: [IgxComboComponent]
3826+
})
3827+
export class ComboArrayTypeValueKeyComponent {
3828+
@ViewChild(IgxComboComponent, { read: IgxComboComponent, static: true })
3829+
public combo: IgxComboComponent;
3830+
public items: any[] = [];
3831+
3832+
constructor() {
3833+
this.items = [
3834+
{
3835+
item: "Item1",
3836+
value: [1, 2, 3]
3837+
},
3838+
{
3839+
item: "Item2",
3840+
value: [4, 5, 6]
3841+
},
3842+
{
3843+
item: "Item3",
3844+
value: [7, 8, 9]
3845+
}
3846+
];
3847+
}
3848+
}

projects/igniteui-angular/src/lib/core/utils.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,6 @@ export const isEqual = (obj1, obj2): boolean => {
226226
return obj1 === obj2;
227227
};
228228

229-
/**
230-
* Checks if provided variable is the value NaN
231-
*
232-
* @param value Value to check
233-
* @returns true if provided variable is NaN
234-
* @hidden
235-
*/
236-
export const isNaNvalue = (value: any): boolean => isNaN(value) && value !== undefined && typeof value !== 'string';
237-
238229
/**
239230
* Utility service taking care of various utility functions such as
240231
* detecting browser features, general cross browser DOM manipulation, etc.
@@ -624,8 +615,8 @@ export function* intoChunks<T>(arr: T[], size: number) {
624615
}
625616

626617
/**
627-
* @param size
628-
* @returns string that represents the --component-size default value
618+
* @param size
619+
* @returns string that represents the --component-size default value
629620
*/
630621
export function getComponentCssSizeVar(size: string) {
631622
switch (size) {

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 */

0 commit comments

Comments
 (0)