Skip to content

Commit 4b0395d

Browse files
committed
fix(igx-combo): integrate overlay settings in combo #1260
1 parent d89f459 commit 4b0395d

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
import { ConnectedPositioningStrategy } from './../services/overlay/position/connected-positioning-strategy';
13
import { CommonModule } from '@angular/common';
24
import {
35
AfterViewInit, ChangeDetectorRef, Component, ContentChild,
@@ -22,6 +24,7 @@ import { IgxInputGroupModule } from '../input-group/input-group.component';
2224
import { IgxComboItemComponent } from './combo-item.component';
2325
import { IgxComboDropDownComponent } from './combo-dropdown.component';
2426
import { IgxComboFilterConditionPipe, IgxComboFilteringPipe, IgxComboGroupingPipe, IgxComboSortingPipe } from './combo.pipes';
27+
import { OverlaySettings, NoOpScrollStrategy } from '../services';
2528

2629
export enum DataTypes {
2730
EMPTY = 'empty',
@@ -95,6 +98,12 @@ export class IgxComboComponent implements AfterViewInit, ControlValueAccessor, O
9598
private _searchInput: ElementRef<HTMLInputElement> = null;
9699
private _comboInput: ElementRef<HTMLInputElement> = null;
97100
private _onChangeCallback: (_: any) => void = noop;
101+
private overlaySettings: OverlaySettings = {
102+
positionStrategy: new ConnectedPositioningStrategy(),
103+
scrollStrategy: new NoOpScrollStrategy(),
104+
modal: false,
105+
closeOnOutsideClick: true
106+
};
98107

99108
private _value = '';
100109
private _searchValue = '';
@@ -383,7 +392,7 @@ export class IgxComboComponent implements AfterViewInit, ControlValueAccessor, O
383392
* ```
384393
*/
385394
@Input()
386-
public itemsMaxWidth = this.width;
395+
public itemsMaxWidth;
387396

388397
/**
389398
* Configures the drop down list item height
@@ -533,7 +542,7 @@ export class IgxComboComponent implements AfterViewInit, ControlValueAccessor, O
533542
evt.preventDefault();
534543
evt.stopPropagation();
535544
if (this.dropdown.collapsed) {
536-
this.dropdown.toggle();
545+
this.toggle();
537546
}
538547
}
539548

@@ -546,7 +555,7 @@ export class IgxComboComponent implements AfterViewInit, ControlValueAccessor, O
546555
evt.preventDefault();
547556
evt.stopPropagation();
548557
if (!this.dropdown.collapsed) {
549-
this.dropdown.toggle();
558+
this.toggle();
550559
}
551560
}
552561

@@ -556,7 +565,7 @@ export class IgxComboComponent implements AfterViewInit, ControlValueAccessor, O
556565
onInputClick(evt) {
557566
evt.stopPropagation();
558567
evt.preventDefault();
559-
this.dropdown.toggle();
568+
this.toggle();
560569
}
561570

562571
get virtualizationState(): IForOfState {
@@ -921,13 +930,15 @@ export class IgxComboComponent implements AfterViewInit, ControlValueAccessor, O
921930
public ngOnInit() {
922931
this.id += currentItem++;
923932
this.selectionAPI.set_selection(this.id, []);
933+
this.overlaySettings.positionStrategy.settings.target = this.elementRef.nativeElement;
924934
}
925935

926936
/**
927937
* @hidden
928938
*/
929939
public ngAfterViewInit() {
930940
this.filteredData = [...this.data];
941+
// this.dropdown.width = this.itemsMaxWidth ? this.itemsMaxWidth : this.elementRef.nativeElement.offsetWidth;
931942
}
932943

933944
/**
@@ -988,12 +999,12 @@ export class IgxComboComponent implements AfterViewInit, ControlValueAccessor, O
988999

9891000
public toggle() {
9901001
this.searchValue = '';
991-
this.dropdown.toggle();
1002+
this.dropdown.toggle(this.overlaySettings);
9921003
}
9931004

9941005
public open() {
9951006
this.searchValue = '';
996-
this.dropdown.open();
1007+
this.dropdown.open(this.overlaySettings);
9971008
}
9981009

9991010
public close() {

0 commit comments

Comments
 (0)