Skip to content

Commit e1afc3f

Browse files
authored
Merge branch '9.1.x' into mvenkov/close-overlay-on-ios-9.1
2 parents bd855a9 + 4671176 commit e1afc3f

File tree

4 files changed

+50
-10
lines changed

4 files changed

+50
-10
lines changed

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

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { configureTestSuite } from '../test-utils/configure-suite';
1919
import { DisplayDensity } from '../core/density';
2020
import { AbsoluteScrollStrategy, ConnectedPositioningStrategy } from '../services/public_api';
2121
import { IgxSelectionAPIService } from '../core/selection';
22-
import { CancelableEventArgs } from '../core/utils';
2322

2423
const CSS_CLASS_COMBO = 'igx-combo';
2524
const CSS_CLASS_COMBO_DROPDOWN = 'igx-combo__drop-down';
@@ -564,6 +563,34 @@ describe('igxCombo', () => {
564563
expect(combo.onSearchInput.emit).toHaveBeenCalledTimes(1);
565564
expect(matchSpy).toHaveBeenCalledTimes(1);
566565
});
566+
it('should not open on click if combo is disabled', () => {
567+
combo = new IgxComboComponent({ nativeElement: null }, mockCdr, mockSelection as any, mockComboService, null, mockInjector);
568+
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['open', 'close', 'toggle']);
569+
const spyObj = jasmine.createSpyObj('event', ['stopPropagation', 'preventDefault']);
570+
combo.ngOnInit();
571+
combo.dropdown = dropdown;
572+
dropdown.collapsed = true;
573+
574+
combo.disabled = true;
575+
combo.onInputClick(spyObj);
576+
expect(combo.dropdown.collapsed).toBeTruthy();
577+
});
578+
it('should not clear value when combo is disabled', () => {
579+
const selectionService = new IgxSelectionAPIService();
580+
combo = new IgxComboComponent({ nativeElement: null }, mockCdr, selectionService, mockComboService, null, mockInjector);
581+
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['selectItem']);
582+
const spyObj = jasmine.createSpyObj('event', ['stopPropagation']);
583+
combo.ngOnInit();
584+
combo.data = data;
585+
combo.dropdown = dropdown;
586+
combo.disabled = true;
587+
spyOnProperty(combo, 'totalItemCount').and.returnValue(combo.data.length);
588+
589+
const item = combo.data.slice(0, 1);
590+
combo.selectItems(item, true);
591+
combo.handleClearItems(spyObj);
592+
expect(combo.value).toEqual(item[0]);
593+
});
567594
});
568595
describe('Initialization and rendering tests: ', () => {
569596
configureTestSuite();
@@ -2469,13 +2496,6 @@ describe('igxCombo', () => {
24692496
expect(combo.valid).toEqual(IgxComboState.INITIAL);
24702497
expect(combo.comboInput.valid).toEqual(IgxInputState.INITIAL);
24712498
});
2472-
it('should not open on click if combo is disabled', () => {
2473-
combo.disabled = true;
2474-
fixture.detectChanges();
2475-
UIInteractions.simulateClickEvent(combo.comboInput.nativeElement);
2476-
fixture.detectChanges();
2477-
expect(combo.dropdown.collapsed).toBeTruthy();
2478-
});
24792499
it('should be possible to be enabled/disabled when used as a form control', () => {
24802500
const form = fixture.componentInstance.reactiveForm;
24812501
const comboFormReference = form.controls.townCombo;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,9 @@ export class IgxComboComponent extends DisplayDensityBase implements IgxComboBas
12761276
* @hidden @internal
12771277
*/
12781278
public handleClearItems(event: Event): void {
1279+
if (this.disabled) {
1280+
return;
1281+
}
12791282
this.deselectAllItems(true, event);
12801283
if (this.collapsed) {
12811284
this.getEditElement().focus();

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,15 @@ describe('IgxTimePicker', () => {
13881388
expect(timePicker.onValidationFailed.emit).toHaveBeenCalled();
13891389
}));
13901390

1391+
it('should trigger onValueChanged if 00:00 is cleared from the input', () => {
1392+
fixture.componentInstance.date = new Date(2018, 10, 27, 0, 0, 0, 0);
1393+
fixture.detectChanges();
1394+
spyOn(timePicker.onValueChanged, 'emit');
1395+
timePicker.clear();
1396+
fixture.detectChanges();
1397+
expect(timePicker.onValueChanged.emit).toHaveBeenCalledTimes(1);
1398+
});
1399+
13911400
it('should scroll on dropdown opened and accept value when focus lost', fakeAsync(() => {
13921401
fixture.detectChanges();
13931402

projects/igniteui-angular/src/lib/time-picker/time-picker.component.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,7 +1901,7 @@ export class IgxTimePickerComponent implements
19011901
// TODO: refactoring - this.value should be null #6585
19021902
this.value?.setHours(0, 0, 0);
19031903

1904-
if (oldVal.getTime() !== this.value.getTime()) {
1904+
if (oldVal.getTime() !== this.value?.getTime() || this.isReset()) {
19051905
const args: IgxTimePickerValueChangedEventArgs = {
19061906
oldValue: oldVal,
19071907
newValue: this.value
@@ -1944,7 +1944,7 @@ export class IgxTimePickerComponent implements
19441944
// TODO: refactoring - this.value should be null #6585
19451945
this.value?.setHours(0, 0, 0);
19461946
this.displayValue = inputMask;
1947-
if (oldVal.getTime() !== this.value?.getTime()) {
1947+
if (oldVal.getTime() !== this.value?.getTime() || this.isReset()) {
19481948
// TODO: Do not emit event when the editor is empty #6482
19491949
const args: IgxTimePickerValueChangedEventArgs = {
19501950
oldValue: oldVal,
@@ -2097,6 +2097,14 @@ export class IgxTimePickerComponent implements
20972097
input.valid = IgxInputState.INITIAL;
20982098
}
20992099
}
2100+
2101+
// Workaround method for #8135
2102+
// TODO: It must be removed in #6482
2103+
private isReset(): boolean {
2104+
return this.value?.getHours() === 0
2105+
&& this.value?.getMinutes() === 0
2106+
&& this.value?.getSeconds() === 0;
2107+
}
21002108
}
21012109

21022110
/**

0 commit comments

Comments
 (0)