Skip to content

Commit c52b609

Browse files
authored
Merge branch '10.1.x' into bpenkov/time-picker-onvaluechanged-10.1
2 parents 16d4f9c + 4a7749d commit c52b609

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

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

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

2423
const CSS_CLASS_COMBO = 'igx-combo';
2524
const CSS_CLASS_COMBO_DROPDOWN = 'igx-combo__drop-down';
@@ -584,6 +583,38 @@ describe('igxCombo', () => {
584583
expect(combo.onSearchInput.emit).toHaveBeenCalledTimes(1);
585584
expect(matchSpy).toHaveBeenCalledTimes(1);
586585
});
586+
it('should not open on click if combo is disabled', () => {
587+
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService,
588+
mockIconService, null, mockInjector);
589+
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['open', 'close', 'toggle']);
590+
const spyObj = jasmine.createSpyObj('event', ['stopPropagation', 'preventDefault']);
591+
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
592+
combo.ngOnInit();
593+
combo.dropdown = dropdown;
594+
dropdown.collapsed = true;
595+
596+
combo.disabled = true;
597+
combo.onInputClick(spyObj);
598+
expect(combo.dropdown.collapsed).toBeTruthy();
599+
});
600+
it('should not clear value when combo is disabled', () => {
601+
const selectionService = new IgxSelectionAPIService();
602+
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService,
603+
mockIconService, null, mockInjector);
604+
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['selectItem']);
605+
const spyObj = jasmine.createSpyObj('event', ['stopPropagation']);
606+
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
607+
combo.ngOnInit();
608+
combo.data = data;
609+
combo.dropdown = dropdown;
610+
combo.disabled = true;
611+
spyOnProperty(combo, 'totalItemCount').and.returnValue(combo.data.length);
612+
613+
const item = combo.data.slice(0, 1);
614+
combo.selectItems(item, true);
615+
combo.handleClearItems(spyObj);
616+
expect(combo.value).toEqual(item[0]);
617+
});
587618
});
588619
describe('Initialization and rendering tests: ', () => {
589620
configureTestSuite();
@@ -2523,13 +2554,6 @@ describe('igxCombo', () => {
25232554
expect(combo.valid).toEqual(IgxComboState.INITIAL);
25242555
expect(combo.comboInput.valid).toEqual(IgxInputState.INITIAL);
25252556
});
2526-
it('should not open on click if combo is disabled', () => {
2527-
combo.disabled = true;
2528-
fixture.detectChanges();
2529-
UIInteractions.simulateClickEvent(combo.comboInput.nativeElement);
2530-
fixture.detectChanges();
2531-
expect(combo.dropdown.collapsed).toBeTruthy();
2532-
});
25332557
it('should be possible to be enabled/disabled when used as a form control', () => {
25342558
const form = fixture.componentInstance.reactiveForm;
25352559
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
@@ -1316,6 +1316,9 @@ export class IgxComboComponent extends DisplayDensityBase implements IgxComboBas
13161316
* @hidden @internal
13171317
*/
13181318
public handleClearItems(event: Event): void {
1319+
if (this.disabled) {
1320+
return;
1321+
}
13191322
this.deselectAllItems(true, event);
13201323
if (this.collapsed) {
13211324
this.getEditElement().focus();

0 commit comments

Comments
 (0)