Skip to content

Commit b924683

Browse files
committed
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular into rkaraivanov/grids-spa-and-wellbeing
2 parents 41e3570 + 5cf3559 commit b924683

File tree

6 files changed

+85
-48
lines changed

6 files changed

+85
-48
lines changed

projects/igniteui-angular/src/lib/combo/combo.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<igx-combo-drop-down #igxComboDropDown class="igx-combo__drop-down" [displayDensity]="displayDensity"
3535
[width]="itemsWidth || '100%'" (onOpening)="handleOpening($event)" (onClosing)="handleClosing($event)"
3636
(onOpened)="handleOpened()" (onClosed)="handleClosed()">
37-
<igx-input-group *ngIf="displaySearchInput" [displayDensity]="displayDensity" class="igx-combo__search">
37+
<igx-input-group *ngIf="displaySearchInput" [displayDensity]="displayDensity" theme="material" class="igx-combo__search">
3838
<input class="igx-combo-input" igxInput #searchInput name="searchInput" autocomplete="off" type="text"
3939
[(ngModel)]="searchValue" (ngModelChange)="handleInputChange($event)" (keyup)="handleKeyUp($event)"
4040
(keydown)="handleKeyDown($event)" (focus)="dropdown.onBlur($event)" [attr.placeholder]="searchPlaceholder"

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -803,12 +803,14 @@ describe('igxCombo', () => {
803803
]
804804
}).compileComponents();
805805
}));
806-
beforeEach(() => {
806+
beforeEach(fakeAsync(() => {
807807
fixture = TestBed.createComponent(IgxComboSampleComponent);
808808
fixture.detectChanges();
809809
combo = fixture.componentInstance.combo;
810810
input = fixture.debugElement.query(By.css(`.${CSS_CLASS_COMBO_INPUTGROUP}`));
811-
});
811+
tick();
812+
fixture.detectChanges();
813+
}));
812814
it('should initialize the combo component properly', () => {
813815
const toggleButton = fixture.debugElement.query(By.css('.' + CSS_CLASS_TOGGLEBUTTON));
814816
expect(fixture.componentInstance).toBeDefined();
@@ -1127,12 +1129,14 @@ describe('igxCombo', () => {
11271129
]
11281130
}).compileComponents();
11291131
}));
1130-
beforeEach(() => {
1132+
beforeEach(fakeAsync(() => {
11311133
fixture = TestBed.createComponent(IgxComboInContainerTestComponent);
11321134
fixture.detectChanges();
11331135
combo = fixture.componentInstance.combo;
11341136
containerElement = fixture.debugElement.query(By.css('.comboContainer')).nativeElement;
1135-
});
1137+
tick();
1138+
fixture.detectChanges();
1139+
}));
11361140
it('should adjust combo width to the container element width when set to 100%', () => {
11371141
const containerWidth = 500;
11381142
const comboWrapper = fixture.debugElement.query(By.css(CSS_CLASS_COMBO)).nativeElement;

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
@@ -241,6 +241,7 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
241241
const reset = filterUIRow.queryAll(By.css('button'))[0];
242242
const close = filterUIRow.queryAll(By.css('button'))[1];
243243
const input = filterUIRow.query(By.directive(IgxInputDirective));
244+
tick();
244245

245246
expect(grid.rowList.length).toEqual(8);
246247

projects/igniteui-angular/src/lib/input-group/input-group.component.spec.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, ViewChild, ElementRef, Inject } from '@angular/core';
2-
import { TestBed, waitForAsync } from '@angular/core/testing';
2+
import { fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
33
import { By } from '@angular/platform-browser';
44
import { IgxInputGroupComponent, IgxInputGroupModule } from './input-group.component';
55
import { DisplayDensityToken, DisplayDensity } from '../core/displayDensity';
@@ -41,58 +41,69 @@ describe('IgxInputGroup', () => {
4141
.compileComponents();
4242
}));
4343

44-
it('Initializes an input group.', () => {
44+
it('Initializes an input group.', fakeAsync(() => {
4545
const fixture = TestBed.createComponent(InputGroupDisabledComponent);
4646
fixture.detectChanges();
4747

4848
const inputGroupElement = fixture.debugElement.query(By.css('igx-input-group')).nativeElement;
4949
expect(inputGroupElement.classList.contains(INPUT_GROUP_CSS_CLASS)).toBe(true);
5050

5151
const igxInputGroup = fixture.componentInstance.igxInputGroup;
52+
tick();
53+
fixture.detectChanges();
5254
// the default type should be line
5355
testInputGroupType('line', igxInputGroup, inputGroupElement);
54-
});
56+
}));
5557

56-
it('Initializes an input group with type box.', () => {
58+
it('Initializes an input group with type box.', fakeAsync(() => {
5759
const fixture = TestBed.createComponent(InputGroupBoxComponent);
5860
fixture.detectChanges();
5961

6062
const inputGroupElement = fixture.debugElement.query(By.css('igx-input-group')).nativeElement;
6163
expect(inputGroupElement.classList.contains(INPUT_GROUP_CSS_CLASS)).toBe(true);
6264

6365
const igxInputGroup = fixture.componentInstance.igxInputGroup;
66+
tick();
67+
fixture.detectChanges();
6468
testInputGroupType('box', igxInputGroup, inputGroupElement);
65-
});
69+
}));
6670

67-
it('Initializes an input group with type border.', () => {
71+
it('Initializes an input group with type border.', fakeAsync(() => {
6872
const fixture = TestBed.createComponent(InputGroupBorderComponent);
6973
fixture.detectChanges();
7074

7175
const inputGroupElement = fixture.debugElement.query(By.css('igx-input-group')).nativeElement;
7276
expect(inputGroupElement.classList.contains(INPUT_GROUP_CSS_CLASS)).toBe(true);
7377

7478
const igxInputGroup = fixture.componentInstance.igxInputGroup;
79+
tick();
80+
fixture.detectChanges();
7581
testInputGroupType('border', igxInputGroup, inputGroupElement);
76-
});
82+
}));
7783

78-
it('Initializes an input group with type search.', () => {
84+
it('Initializes an input group with type search.', fakeAsync(() => {
7985
const fixture = TestBed.createComponent(InputGroupSearchComponent);
8086
fixture.detectChanges();
8187

8288
const inputGroupElement = fixture.debugElement.query(By.css('igx-input-group')).nativeElement;
8389
expect(inputGroupElement.classList.contains(INPUT_GROUP_CSS_CLASS)).toBe(true);
8490

8591
const igxInputGroup = fixture.componentInstance.igxInputGroup;
92+
tick();
93+
fixture.detectChanges();
8694
testInputGroupType('search', igxInputGroup, inputGroupElement);
87-
});
95+
}));
8896

89-
it('Should respect type Token and be able to change input group type programmatically.', () => {
97+
it('Should respect type Token and be able to change input group type programmatically.', fakeAsync(() => {
9098
const fixture = TestBed.createComponent(InputGroupComponent);
9199
fixture.detectChanges();
92100

93101
const inputGroupElement = fixture.debugElement.query(By.css('igx-input-group')).nativeElement;
94102
const igxInputGroup = fixture.componentInstance.igxInputGroup;
95103

104+
tick();
105+
fixture.detectChanges();
106+
96107
// a Token is passed and can be obtained
97108
expect(fixture.componentInstance.IGTOKEN).toBe('box');
98109

@@ -120,7 +131,7 @@ describe('IgxInputGroup', () => {
120131
igxInputGroup.type = null;
121132
fixture.detectChanges();
122133
testInputGroupType('box', igxInputGroup, inputGroupElement);
123-
});
134+
}));
124135

125136
it('disabled input should properly detect changes.', () => {
126137
const fixture = TestBed.createComponent(InputGroupDisabledComponent);

projects/igniteui-angular/src/lib/input-group/input-group.component.ts

Lines changed: 51 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { CommonModule, DOCUMENT } from '@angular/common';
22
import {
3+
AfterViewInit,
34
Component,
45
ContentChild,
56
ContentChildren,
@@ -11,8 +12,8 @@ import {
1112
QueryList,
1213
Inject,
1314
Optional,
14-
AfterContentInit,
15-
Renderer2,
15+
OnDestroy,
16+
ChangeDetectorRef,
1617
} from '@angular/core';
1718
import { IgxHintDirective } from '../directives/hint/hint.directive';
1819
import {
@@ -36,6 +37,7 @@ import { IInputResourceStrings } from '../core/i18n/input-resources';
3637
import { CurrentResourceStrings } from '../core/i18n/resources';
3738

3839
import { mkenum, PlatformUtil } from '../core/utils';
40+
import { Subject, Subscription } from 'rxjs';
3941

4042
const IgxInputGroupTheme = mkenum({
4143
Material: 'material',
@@ -54,7 +56,7 @@ export type IgxInputGroupTheme = (typeof IgxInputGroupTheme)[keyof typeof IgxInp
5456
templateUrl: 'input-group.component.html',
5557
providers: [{ provide: IgxInputGroupBase, useExisting: IgxInputGroupComponent }],
5658
})
57-
export class IgxInputGroupComponent extends DisplayDensityBase implements IgxInputGroupBase, AfterContentInit {
59+
export class IgxInputGroupComponent extends DisplayDensityBase implements IgxInputGroupBase, AfterViewInit, OnDestroy {
5860
/**
5961
* Sets the resource strings.
6062
* By default it uses EN resources.
@@ -135,7 +137,9 @@ export class IgxInputGroupComponent extends DisplayDensityBase implements IgxInp
135137

136138
private _type: IgxInputGroupType = null;
137139
private _filled = false;
138-
private _variant: IgxInputGroupTheme;
140+
private _theme: IgxInputGroupTheme;
141+
private _theme$ = new Subject();
142+
private _subscription: Subscription;
139143
private _resourceStrings = CurrentResourceStrings.InputResStrings;
140144

141145
/** @hidden */
@@ -212,13 +216,13 @@ export class IgxInputGroupComponent extends DisplayDensityBase implements IgxInp
212216
* }
213217
*/
214218
@Input()
215-
public set theme(variant: IgxInputGroupTheme) {
216-
this._variant = variant;
219+
public set theme(value: IgxInputGroupTheme) {
220+
this._theme = value;
217221
}
218222

219223
/**
220224
* Returns the theme of the input.
221-
* The returned value is of tyep IgxInputGroupType.
225+
* The returned value is of type IgxInputGroupType.
222226
* ```typescript
223227
* @ViewChild("MyInputGroup")
224228
* public inputGroup: IgxInputGroupComponent;
@@ -227,7 +231,7 @@ export class IgxInputGroupComponent extends DisplayDensityBase implements IgxInp
227231
* }
228232
*/
229233
public get theme(): IgxInputGroupTheme {
230-
return this._variant;
234+
return this._theme;
231235
}
232236

233237
constructor(
@@ -240,10 +244,15 @@ export class IgxInputGroupComponent extends DisplayDensityBase implements IgxInp
240244
private _inputGroupType: IgxInputGroupType,
241245
@Inject(DOCUMENT)
242246
private document: any,
243-
private renderer: Renderer2,
244-
private platform: PlatformUtil
247+
private platform: PlatformUtil,
248+
private cdr: ChangeDetectorRef
245249
) {
246250
super(_displayDensityOptions);
251+
252+
this._subscription = this._theme$.asObservable().subscribe(value => {
253+
this._theme = value as IgxInputGroupTheme;
254+
this.cdr.detectChanges();
255+
});
247256
}
248257

249258
/** @hidden */
@@ -271,19 +280,6 @@ export class IgxInputGroupComponent extends DisplayDensityBase implements IgxInp
271280
event.stopPropagation();
272281
}
273282

274-
/** @hidden @internal */
275-
public ngAfterContentInit() {
276-
if (!this.theme) {
277-
if(this.platform.isIE) {
278-
this._variant = IgxInputGroupTheme.Material;
279-
} else {
280-
this._variant = this.document.defaultView
281-
.getComputedStyle(this.element.nativeElement)
282-
.getPropertyValue('--theme')
283-
.trim() as IgxInputGroupTheme;
284-
}
285-
}
286-
}
287283
/**
288284
* Returns whether the `IgxInputGroupComponent` has hints.
289285
* ```typescript
@@ -311,7 +307,7 @@ export class IgxInputGroupComponent extends DisplayDensityBase implements IgxInp
311307
public get hasBorder() {
312308
return (
313309
(this.type === 'line' || this.type === 'box') &&
314-
this._variant === 'material'
310+
this._theme === 'material'
315311
);
316312
}
317313

@@ -326,7 +322,7 @@ export class IgxInputGroupComponent extends DisplayDensityBase implements IgxInp
326322
* ```
327323
*/
328324
public get isTypeLine(): boolean {
329-
return this.type === 'line' && this._variant === 'material';
325+
return this.type === 'line' && this._theme === 'material';
330326
}
331327

332328
/**
@@ -341,7 +337,7 @@ export class IgxInputGroupComponent extends DisplayDensityBase implements IgxInp
341337
*/
342338
@HostBinding('class.igx-input-group--box')
343339
public get isTypeBox() {
344-
return this.type === 'box' && this._variant === 'material';
340+
return this.type === 'box' && this._theme === 'material';
345341
}
346342

347343
/** @hidden @internal */
@@ -377,7 +373,7 @@ export class IgxInputGroupComponent extends DisplayDensityBase implements IgxInp
377373
*/
378374
@HostBinding('class.igx-input-group--border')
379375
public get isTypeBorder() {
380-
return this.type === 'border' && this._variant === 'material';
376+
return this.type === 'border' && this._theme === 'material';
381377
}
382378

383379
/**
@@ -392,7 +388,7 @@ export class IgxInputGroupComponent extends DisplayDensityBase implements IgxInp
392388
*/
393389
@HostBinding('class.igx-input-group--fluent')
394390
public get isTypeFluent() {
395-
return this._variant === 'fluent';
391+
return this._theme === 'fluent';
396392
}
397393

398394
/**
@@ -407,7 +403,7 @@ export class IgxInputGroupComponent extends DisplayDensityBase implements IgxInp
407403
*/
408404
@HostBinding('class.igx-input-group--bootstrap')
409405
public get isTypeBootstrap() {
410-
return this._variant === 'bootstrap';
406+
return this._theme === 'bootstrap';
411407
}
412408

413409
/**
@@ -422,7 +418,7 @@ export class IgxInputGroupComponent extends DisplayDensityBase implements IgxInp
422418
*/
423419
@HostBinding('class.igx-input-group--indigo')
424420
public get isTypeIndigo() {
425-
return this._variant === 'indigo-design';
421+
return this._theme === 'indigo-design';
426422
}
427423

428424
/**
@@ -449,6 +445,31 @@ export class IgxInputGroupComponent extends DisplayDensityBase implements IgxInp
449445
public set filled(val) {
450446
this._filled = val;
451447
}
448+
449+
/** @hidden @internal */
450+
public ngAfterViewInit() {
451+
if (!this._theme) {
452+
if(this.platform.isIE) {
453+
Promise.resolve().then(() => {
454+
this._theme$.next(IgxInputGroupTheme.Material);
455+
});
456+
} else {
457+
const cssProp = this.document.defaultView
458+
.getComputedStyle(this.element.nativeElement)
459+
.getPropertyValue('--theme')
460+
.trim();
461+
462+
Promise.resolve().then(() => {
463+
this._theme$.next(cssProp);
464+
});
465+
}
466+
}
467+
}
468+
469+
/** @hidden @internal */
470+
public ngOnDestroy() {
471+
this._subscription.unsubscribe();
472+
}
452473
}
453474

454475
/** @hidden */

src/app/dialog/dialog.sample.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ <h4 class="sample-title">Templated Dialog</h4>
100100
<igx-dialog-title>Title</igx-dialog-title>
101101

102102
<div class="login-form">
103-
<igx-input-group>
103+
<igx-input-group theme="material" type="box">
104104
<igx-prefix>
105105
<igx-icon>person</igx-icon>
106106
</igx-prefix>
107107
<input type="text" igxInput />
108108
<label igxLabel>Username</label>
109109
</igx-input-group>
110-
<igx-input-group>
110+
<igx-input-group type="box">
111111
<igx-prefix>
112112
<igx-icon>lock</igx-icon>
113113
</igx-prefix>

0 commit comments

Comments
 (0)