Skip to content

Commit 577cee4

Browse files
committed
Merge remote-tracking branch 'origin/master' into mpopov/chip-discrepancy
# Conflicts: # projects/igniteui-angular/src/lib/chips/chip.component.ts
2 parents aabd006 + 33d7d9e commit 577cee4

26 files changed

+229
-126
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ All notable changes for each version of this project will be documented in this
7373
- **Breaking Changes** - ` $label-floated-background` and `$label-floated-disabled-background` properties of `IgxInputGroupComponent` theme has been removed.
7474
- `IgxInputGroupComponent` The input group has been refactored so that the floating label for the input of `type="border"` does not require a background to match the surface background under the input field. Also, suffixes and prefixes are refactored to take the full height of the input which makes it easy to add background to them.
7575
- **Breaking Changes** - `$size` property of `scrollbar-theme` theme has been renamed to `$scrollbar-size`.
76+
- `IgxSimpleCombo`
77+
- The `IgxSimpleCombo` will not open its drop-down on clear.
7678

7779
## 15.0.1
7880

projects/igniteui-angular/src/lib/chips/chip.component.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
Renderer2,
1212
TemplateRef,
1313
Inject,
14-
Optional
14+
Optional,
15+
OnDestroy
1516
} from '@angular/core';
1617
import { IDisplayDensityOptions, DisplayDensityToken, DisplayDensityBase } from '../core/displayDensity';
1718
import {
@@ -24,6 +25,8 @@ import {
2425
import {IBaseEventArgs, mkenum} from '../core/utils';
2526
import { IChipResourceStrings } from '../core/i18n/chip-resources';
2627
import { CurrentResourceStrings } from '../core/i18n/resources';
28+
import { fromEvent, Subject } from 'rxjs';
29+
import { take, filter } from 'rxjs/operators';
2730

2831
export const IgxChipTypeVariant = mkenum({
2932
PRIMARY: 'primary',
@@ -85,7 +88,7 @@ let CHIP_ID = 0;
8588
selector: 'igx-chip',
8689
templateUrl: 'chip.component.html'
8790
})
88-
export class IgxChipComponent extends DisplayDensityBase {
91+
export class IgxChipComponent extends DisplayDensityBase implements OnDestroy {
8992

9093
/**
9194
* Sets/gets the variant of the chip.
@@ -101,7 +104,6 @@ export class IgxChipComponent extends DisplayDensityBase {
101104
*/
102105
@Input()
103106
public variant: string | typeof IgxChipTypeVariant;
104-
105107
/**
106108
* An @Input property that sets the value of `id` attribute. If not provided it will be automatically generated.
107109
*
@@ -599,6 +601,12 @@ export class IgxChipComponent extends DisplayDensityBase {
599601
*/
600602
public hideBaseElement = false;
601603

604+
/**
605+
* @hidden
606+
* @internal
607+
*/
608+
public destroy$ = new Subject();
609+
602610
protected _tabIndex = null;
603611
protected _selected = false;
604612
protected _selectedItemClass = 'igx-chip__item--selected';
@@ -897,4 +905,9 @@ export class IgxChipComponent extends DisplayDensityBase {
897905
}
898906
}
899907
}
908+
909+
public ngOnDestroy(): void {
910+
this.destroy$.next();
911+
this.destroy$.complete();
912+
}
900913
}

projects/igniteui-angular/src/lib/chips/chips-area.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,20 +223,20 @@ export class IgxChipsAreaComponent implements DoCheck, AfterViewInit, OnDestroy
223223
const changes = this._differ.diff(this.chipsList.toArray());
224224
if (changes) {
225225
changes.forEachAddedItem((addedChip) => {
226-
addedChip.item.moveStart.pipe(takeUntil(this.destroy$)).subscribe((args) => {
226+
addedChip.item.moveStart.pipe(takeUntil(addedChip.item.destroy$)).subscribe((args) => {
227227
this.onChipMoveStart(args);
228228
});
229-
addedChip.item.moveEnd.pipe(takeUntil(this.destroy$)).subscribe((args) => {
229+
addedChip.item.moveEnd.pipe(takeUntil(addedChip.item.destroy$)).subscribe((args) => {
230230
this.onChipMoveEnd(args);
231231
});
232-
addedChip.item.dragEnter.pipe(takeUntil(this.destroy$)).subscribe((args) => {
232+
addedChip.item.dragEnter.pipe(takeUntil(addedChip.item.destroy$)).subscribe((args) => {
233233
this.onChipDragEnter(args);
234234
});
235-
addedChip.item.keyDown.pipe(takeUntil(this.destroy$)).subscribe((args) => {
235+
addedChip.item.keyDown.pipe(takeUntil(addedChip.item.destroy$)).subscribe((args) => {
236236
this.onChipKeyDown(args);
237237
});
238238
if (addedChip.item.selectable) {
239-
addedChip.item.selectedChanging.pipe(takeUntil(this.destroy$)).subscribe((args) => {
239+
addedChip.item.selectedChanging.pipe(takeUntil(addedChip.item.destroy$)).subscribe((args) => {
240240
this.onChipSelectionChange(args);
241241
});
242242
}

projects/igniteui-angular/src/lib/core/styles/components/grid/_grid-theme.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,9 +2163,10 @@
21632163
}
21642164

21652165
%igx-group-label__count-badge {
2166-
> div {
2167-
background: var-get($theme, 'group-count-background');
2168-
color: var-get($theme, 'group-count-text-color');
2166+
--background-color: #{var-get($theme, 'group-count-background')};
2167+
--text-color: #{var-get($theme, 'group-count-text-color')};
2168+
2169+
> span {
21692170
font-size: $grid-head-fs;
21702171
}
21712172
}

projects/igniteui-angular/src/lib/core/styles/components/input/_input-group-theme.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@
534534
height: var(--size);
535535
position: relative;
536536
max-width: 100%;
537-
font-size: 1rem;
537+
font-size: rem(16px);
538538

539539
&::after {
540540
content: '';
@@ -1896,7 +1896,6 @@
18961896

18971897
%form-group-input {
18981898
@include type-style($input-text) {
1899-
font-size: 16px;
19001899
margin: 0;
19011900
}
19021901
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
AfterViewInit,
44
ChangeDetectorRef,
55
Component,
6-
ComponentFactoryResolver,
76
Directive,
87
Injectable,
98
IterableDiffers,
@@ -1336,7 +1335,6 @@ export class TestIgxForOfDirective<T> extends IgxForOfDirective<T> {
13361335
public viewContainer: ViewContainerRef,
13371336
public template: TemplateRef<NgForOfContext<T>>,
13381337
public differs: IterableDiffers,
1339-
public fResolver: ComponentFactoryResolver,
13401338
public changeDet: ChangeDetectorRef,
13411339
public zone: NgZone,
13421340
protected syncService: IgxForOfScrollSyncService,

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

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import {
44
AfterViewInit,
55
ApplicationRef,
66
ChangeDetectorRef,
7-
ComponentFactory,
8-
ComponentFactoryResolver,
97
ComponentRef,
108
ContentChild,
119
ContentChildren,
10+
createComponent,
1211
Directive,
1312
DoCheck,
1413
ElementRef,
14+
EnvironmentInjector,
1515
EventEmitter,
1616
HostBinding,
1717
HostListener,
@@ -21,7 +21,6 @@ import {
2121
IterableChangeRecord,
2222
IterableDiffers,
2323
LOCALE_ID,
24-
NgModuleRef,
2524
NgZone,
2625
OnDestroy,
2726
OnInit,
@@ -3351,12 +3350,11 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
33513350
protected zone: NgZone,
33523351
@Inject(DOCUMENT) public document: any,
33533352
public cdr: ChangeDetectorRef,
3354-
protected resolver: ComponentFactoryResolver,
33553353
protected differs: IterableDiffers,
33563354
protected viewRef: ViewContainerRef,
33573355
private appRef: ApplicationRef,
3358-
private moduleRef: NgModuleRef<any>,
3359-
private injector: Injector,
3356+
protected injector: Injector,
3357+
protected envInjector: EnvironmentInjector,
33603358
public navigation: IgxGridNavigationService,
33613359
public filteringService: IgxFilteringService,
33623360
@Inject(IgxOverlayService) protected overlayService: IgxOverlayService,
@@ -3835,26 +3833,8 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
38353833
}
38363834

38373835
private createComponentInstance(component: any) {
3838-
// TODO: create component instance view viewContainerRef.createComponent(Component, Settings) overload
3839-
let dynamicFactory: ComponentFactory<any>;
3840-
const factoryResolver = this.moduleRef
3841-
? this.moduleRef.componentFactoryResolver
3842-
: this.resolver;
3843-
try {
3844-
dynamicFactory = factoryResolver.resolveComponentFactory(component);
3845-
} catch (error) {
3846-
console.error(error);
3847-
return null;
3848-
}
3849-
3850-
const injector = this.moduleRef
3851-
? this.moduleRef.injector
3852-
: this.injector;
3853-
const dynamicComponent: ComponentRef<any> = dynamicFactory.create(
3854-
injector
3855-
);
3836+
const dynamicComponent: ComponentRef<any> = createComponent(component, { environmentInjector: this.envInjector, elementInjector: this.injector } );
38563837
this.appRef.attachView(dynamicComponent.hostView);
3857-
38583838
return dynamicComponent;
38593839
}
38603840

@@ -7156,12 +7136,11 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
71567136
*/
71577137
protected autogenerateColumns() {
71587138
const data = this.gridAPI.get_data();
7159-
const factory = this.resolver.resolveComponentFactory(IgxColumnComponent);
71607139
const fields = this.generateDataFields(data);
71617140
const columns = [];
71627141

71637142
fields.forEach((field) => {
7164-
const ref = factory.create(this.viewRef.injector);
7143+
const ref = createComponent(IgxColumnComponent, { environmentInjector: this.envInjector, elementInjector: this.injector});
71657144
ref.instance.field = field;
71667145
ref.instance.dataType = this.resolveDataTypes(data[0][field]);
71677146
ref.changeDetectorRef.detectChanges();

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

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,63 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
21302130
expect(GridFunctions.getAdvancedFilteringTreeChildItems(secondItem, false).length).toBe(1);
21312131
}));
21322132

2133+
it('Should respect the changes of the groups applied from the context menu.',
2134+
fakeAsync(() => {
2135+
// Apply advanced filter through API.
2136+
const tree = new FilteringExpressionsTree(FilteringLogic.And);
2137+
tree.filteringOperands.push({
2138+
fieldName: 'ProductName', searchVal: 'angular', condition: IgxStringFilteringOperand.instance().condition('contains'),
2139+
ignoreCase: true
2140+
});
2141+
tree.filteringOperands.push({
2142+
fieldName: 'ProductName', searchVal: 'script', condition: IgxStringFilteringOperand.instance().condition('contains'),
2143+
ignoreCase: true
2144+
});
2145+
grid.advancedFilteringExpressionsTree = tree;
2146+
fix.detectChanges();
2147+
2148+
// Verify the filter changes are applied.
2149+
expect(grid.filteredData.length).toEqual(0);
2150+
2151+
// Open Advanced Filtering dialog.
2152+
grid.openAdvancedFilteringDialog();
2153+
fix.detectChanges();
2154+
2155+
// Verify tree layout before the group change through context menu.
2156+
let rootGroup = GridFunctions.getAdvancedFilteringTreeRootGroup(fix);
2157+
expect(GridFunctions.getAdvancedFilteringTreeChildItems(rootGroup, true).length).toBe(2);
2158+
expect(GridFunctions.getAdvancedFilteringTreeChildItems(rootGroup, false).length).toBe(2);
2159+
2160+
// Select two chips.
2161+
GridFunctions.clickAdvancedFilteringTreeExpressionChip(fix, [0]);
2162+
GridFunctions.clickAdvancedFilteringTreeExpressionChip(fix, [1]);
2163+
tick(200);
2164+
2165+
// Click "Create Or Group" in context menu.
2166+
const buttons = GridFunctions.getAdvancedFilteringContextMenuButtons(fix);
2167+
buttons[2].click();
2168+
tick(100);
2169+
fix.detectChanges();
2170+
2171+
// Close dialog through API.
2172+
grid.closeAdvancedFilteringDialog(true);
2173+
tick(100);
2174+
fix.detectChanges();
2175+
2176+
// Open Advanced Filtering dialog.
2177+
grid.openAdvancedFilteringDialog();
2178+
fix.detectChanges();
2179+
2180+
// Verify tree layout after the group change through context menu.
2181+
rootGroup = GridFunctions.getAdvancedFilteringTreeRootGroup(fix);
2182+
expect(GridFunctions.getAdvancedFilteringTreeChildItems(rootGroup, true).length).toBe(1);
2183+
expect(GridFunctions.getAdvancedFilteringTreeChildItems(rootGroup, false).length).toBe(3);
2184+
2185+
// Verify the filter changes are applied.
2186+
expect(grid.filteredData.length).toEqual(3);
2187+
}));
2188+
2189+
21332190
it('Should delete all selected conditions when the \'delete filters\' option from context menu is clicked.',
21342191
fakeAsync(() => {
21352192
// Apply advanced filter through API.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,6 +2118,7 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
21182118
expect(grid.rowList.length).toEqual(1);
21192119

21202120
// This Month condition
2121+
const expectedResults = GridFunctions.createDateFilterConditions(grid, today);
21212122
GridFunctions.openFilterDDAndSelectCondition(fix, 6);
21222123
tick();
21232124
fix.detectChanges();

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

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import {
22
ApplicationRef,
33
ChangeDetectorRef,
4-
ComponentFactoryResolver,
4+
createComponent,
55
Directive,
66
ElementRef,
7+
EnvironmentInjector,
78
EventEmitter,
89
Inject,
910
Injector,
1011
Input,
1112
IterableDiffers,
1213
LOCALE_ID,
13-
NgModuleRef,
1414
NgZone,
1515
Optional,
1616
Output,
17+
reflectComponentType,
1718
TemplateRef,
1819
ViewChild,
1920
ViewContainerRef
@@ -158,12 +159,11 @@ export abstract class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirect
158159
zone: NgZone,
159160
@Inject(DOCUMENT) public document,
160161
cdr: ChangeDetectorRef,
161-
resolver: ComponentFactoryResolver,
162162
differs: IterableDiffers,
163163
viewRef: ViewContainerRef,
164164
appRef: ApplicationRef,
165-
moduleRef: NgModuleRef<any>,
166165
injector: Injector,
166+
envInjector: EnvironmentInjector,
167167
navigation: IgxHierarchicalGridNavigationService,
168168
filteringService: IgxFilteringService,
169169
@Inject(IgxOverlayService) protected overlayService: IgxOverlayService,
@@ -182,12 +182,11 @@ export abstract class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirect
182182
zone,
183183
document,
184184
cdr,
185-
resolver,
186185
differs,
187186
viewRef,
188187
appRef,
189-
moduleRef,
190188
injector,
189+
envInjector,
191190
navigation,
192191
filteringService,
193192
overlayService,
@@ -212,8 +211,8 @@ export abstract class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirect
212211
this.updateColumns(result);
213212
this.initPinning();
214213

215-
const factoryColumn = this.resolver.resolveComponentFactory(IgxColumnComponent);
216-
const outputs = factoryColumn.outputs.filter(o => o.propName !== 'columnChange');
214+
const mirror = reflectComponentType(IgxColumnComponent);
215+
const outputs = mirror.outputs.filter(o => o.propName !== 'columnChange');
217216
outputs.forEach(output => {
218217
this.columns.forEach(column => {
219218
if (column[output.propName]) {
@@ -237,10 +236,10 @@ export abstract class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirect
237236
}
238237

239238
protected _createColGroupComponent(col: IgxColumnGroupComponent) {
240-
const factoryGroup = this.resolver.resolveComponentFactory(IgxColumnGroupComponent);
241-
const ref = this.viewRef.createComponent(IgxColumnGroupComponent, { injector: this.viewRef.injector });
239+
const ref = createComponent(IgxColumnGroupComponent, { environmentInjector: this.envInjector, elementInjector: this.injector });
242240
ref.changeDetectorRef.detectChanges();
243-
factoryGroup.inputs.forEach((input) => {
241+
const mirror = reflectComponentType(IgxColumnGroupComponent);
242+
mirror.inputs.forEach((input) => {
244243
const propName = input.propName;
245244
ref.instance[propName] = col[propName];
246245
});
@@ -258,9 +257,9 @@ export abstract class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirect
258257
}
259258

260259
protected _createColComponent(col) {
261-
const factoryColumn = this.resolver.resolveComponentFactory(IgxColumnComponent);
262-
const ref = this.viewRef.createComponent(IgxColumnComponent, { injector: this.viewRef.injector });
263-
factoryColumn.inputs.forEach((input) => {
260+
const ref = createComponent(IgxColumnComponent, { environmentInjector: this.envInjector, elementInjector: this.injector });
261+
const mirror = reflectComponentType(IgxColumnComponent);
262+
mirror.inputs.forEach((input) => {
264263
const propName = input.propName;
265264
if (!(col[propName] instanceof IgxSummaryOperand)) {
266265
ref.instance[propName] = col[propName];

0 commit comments

Comments
 (0)