Skip to content

Commit 06dc59e

Browse files
committed
chore(select): Address comments #7487
1 parent a2e37ca commit 06dc59e

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { FormsModule, FormGroup, FormBuilder, FormControl, Validators, ReactiveF
55
import { By } from '@angular/platform-browser';
66
import { IgxDropDownModule, IgxDropDownItemComponent } from '../drop-down/index';
77
import { IgxIconModule } from '../icon/index';
8-
import { IgxInputGroupModule } from '../input-group/index';
8+
import { IgxInputGroupModule, IgxHintDirective } from '../input-group/index';
99
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
1010
import { IgxSelectComponent } from './select.component';
1111
import { IgxSelectItemComponent } from './select-item.component';
@@ -17,8 +17,6 @@ import { IgxSelectModule } from './select.module';
1717

1818
const CSS_CLASS_INPUT_GROUP = 'igx-input-group';
1919
const CSS_CLASS_INPUT = 'igx-input-group__input';
20-
const CSS_CLASS_INPUT_GROUP_HINT = 'igx-input-group__hint';
21-
const CSS_CLASS_HINT = 'igx-input-group__hint-item--start';
2220
const CSS_CLASS_TOGGLE_BUTTON = 'igx-icon';
2321
const CSS_CLASS_DROPDOWN_LIST_SCROLL = 'igx-drop-down__list-scroll';
2422
const CSS_CLASS_DROPDOWN_LIST = 'igx-drop-down__list';
@@ -2519,21 +2517,23 @@ describe('igxSelect', () => {
25192517
}));
25202518
it('should not open dropdown on hint container click',
25212519
fakeAsync(() => {
2522-
const hintContainer = fixture.debugElement.query(By.css('.' + CSS_CLASS_INPUT_GROUP_HINT));
2523-
expect(select.collapsed).toBeTruthy();
2524-
hintContainer.nativeElement.click();
2525-
tick();
2526-
fixture.detectChanges();
2527-
expect(select.collapsed).toBeTruthy();
2520+
const hint = fixture.debugElement.query(By.directive(IgxHintDirective));
2521+
const hintContainer: HTMLElement = hint.nativeElement.parentElement;
2522+
2523+
expect(select.collapsed).toBeTruthy();
2524+
hintContainer.click();
2525+
tick();
2526+
fixture.detectChanges();
2527+
expect(select.collapsed).toBeTruthy();
25282528
}));
25292529
it('should not open dropdown on hint element click',
25302530
fakeAsync(() => {
2531-
const hint = fixture.debugElement.query(By.css('.' + CSS_CLASS_HINT));
2532-
expect(select.collapsed).toBeTruthy();
2533-
hint.nativeElement.click();
2534-
tick();
2535-
fixture.detectChanges();
2536-
expect(select.collapsed).toBeTruthy();
2531+
const hint = fixture.debugElement.query(By.directive(IgxHintDirective));
2532+
expect(select.collapsed).toBeTruthy();
2533+
hint.nativeElement.click();
2534+
tick();
2535+
fixture.detectChanges();
2536+
expect(select.collapsed).toBeTruthy();
25372537
}));
25382538
});
25392539
});

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { IgxSelectBase } from './select.common';
2323
import { EditorProvider } from '../core/edit-provider';
2424
import { IgxSelectionAPIService } from '../core/selection';
2525
import { DisplayDensityToken, IDisplayDensityOptions } from '../core/density';
26+
import { IgxHintDirective } from '../directives/hint/hint.directive';
2627

2728
/** @hidden @internal */
2829
@Directive({
@@ -92,6 +93,9 @@ export class IgxSelectComponent extends IgxDropDownComponent implements IgxSelec
9293
/** @hidden @internal */
9394
@ViewChild('input', { read: IgxInputDirective, static: true }) public input: IgxInputDirective;
9495

96+
/** @hidden @internal */
97+
@ContentChild(IgxHintDirective, { read: ElementRef }) hintElement: ElementRef;
98+
9599
/** @hidden @internal */
96100
@ContentChildren(forwardRef(() => IgxSelectItemComponent), { descendants: true })
97101
public children: QueryList<IgxSelectItemComponent>;
@@ -342,11 +346,13 @@ export class IgxSelectComponent extends IgxDropDownComponent implements IgxSelec
342346
}
343347

344348
public inputGroupClick(event: MouseEvent, overlaySettings?: OverlaySettings) {
345-
const targetClass = (event.target as HTMLElement).className;
346-
if (!targetClass.includes('igx-input-group__hint')) {
347-
this.toggle(Object.assign({}, this._overlayDefaults, this.overlaySettings, overlaySettings));
349+
const targetElement = event.target as HTMLElement;
350+
351+
if (this.hintElement && targetElement.contains(this.hintElement.nativeElement)) {
352+
return;
348353
}
349-
}
354+
this.toggle(Object.assign({}, this._overlayDefaults, this.overlaySettings, overlaySettings));
355+
}
350356

351357
/** @hidden @internal */
352358
ngAfterContentInit() {

0 commit comments

Comments
 (0)