Skip to content

Commit ff3e128

Browse files
authored
Merge pull request #7549 from IgniteUI/ibarakov/fix-7072-9.1.x
Use IgxSelect instead of IgxDropdown #7072
2 parents 10c3b60 + 444551f commit ff3e128

File tree

5 files changed

+72
-115
lines changed

5 files changed

+72
-115
lines changed

projects/igniteui-angular/src/lib/core/styles/components/grid/_excel-filtering-theme.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@
387387
align-items: center;
388388
padding: 0 rem(16px);
389389

390-
igx-input-group {
390+
igx-select {
391391
flex-grow: 1;
392392
flex-basis: 40%;
393393
margin: rem(16px) 0;

projects/igniteui-angular/src/lib/grids/filtering/excel-style/excel-style-date-expression.component.html

+16-30
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,18 @@
1-
<igx-drop-down
2-
#dropdownConditions
3-
[maxHeight]="'200px'"
4-
[width]="getInputWidth()"
5-
[displayDensity]="displayDensity"
6-
(onSelection)="onConditionsChanged($event)">
7-
<igx-drop-down-item *ngFor="let condition of conditions" [value]="condition" [selected]="isConditionSelected(condition)">
8-
<igx-icon fontSet="filtering-icons" [name]="getCondition(condition).iconName"></igx-icon>
9-
<span>{{ translateCondition(condition) }}</span>
10-
</igx-drop-down-item>
11-
</igx-drop-down>
12-
13-
<igx-input-group
14-
#inputGroupConditions
15-
(click)="toggleCustomDialogDropDown()"
16-
type="box"
17-
[displayDensity]="displayDensity">
18-
1+
<igx-select #dropdownConditions
2+
type="box"
3+
[displayDensity]="displayDensity"
4+
[placeholder]="conditionsPlaceholder"
5+
(onSelection)="onConditionsChanged($event)"
6+
[overlaySettings]="dropDownOverlaySettings">
197
<igx-prefix>
208
<igx-icon *ngIf="expressionUI.expression.condition" fontSet="filtering-icons" [name]="getIconName()"></igx-icon>
219
<igx-icon *ngIf="!expressionUI.expression.condition">filter_list</igx-icon>
2210
</igx-prefix>
23-
24-
<input
25-
igxInput
26-
(keydown)="onInputConditionsKeyDown($event)"
27-
tabindex="0"
28-
[igxDropDownItemNavigation]="dropdownConditions"
29-
[placeholder]="inputConditionsPlaceholder"
30-
autocomplete="off"
31-
[value]="getConditionName(expressionUI.expression.condition)"
32-
[readonly]="true"
33-
/>
34-
</igx-input-group>
11+
<igx-select-item *ngFor="let condition of conditions" [value]="condition" [selected]="isConditionSelected(condition)">
12+
<igx-icon fontSet="filtering-icons" [name]="getCondition(condition).iconName"></igx-icon>
13+
<span>{{translateCondition(condition)}}</span>
14+
</igx-select-item>
15+
</igx-select>
3516

3617
<igx-date-picker #datePicker mode="dropdown" [(ngModel)]="expressionUI.expression.searchVal" [locale]="grid.locale" [outlet]="grid.outletDirective">
3718
<ng-template igxDatePickerTemplate let-openDialog="openDialog" let-value="value">
@@ -76,3 +57,8 @@
7657
{{ grid.resourceStrings.igx_grid_filter_operator_or }}
7758
</span>
7859
</igx-buttongroup>
60+
61+
<div #overlayOutlet
62+
igxOverlayOutlet
63+
(pointerdown)="onOutletPointerDown($event)">
64+
</div>

projects/igniteui-angular/src/lib/grids/filtering/excel-style/excel-style-default-expression.component.html

+16-30
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,18 @@
1-
<igx-drop-down
2-
#dropdownConditions
3-
[maxHeight]="'200px'"
4-
[width]="getInputWidth()"
5-
[displayDensity]="displayDensity"
6-
(onSelection)="onConditionsChanged($event)">
7-
<igx-drop-down-item *ngFor="let condition of conditions" [value]="condition" [selected]="isConditionSelected(condition)">
8-
<igx-icon fontSet="filtering-icons" [name]="getCondition(condition).iconName"></igx-icon>
9-
<span>{{ translateCondition(condition) }}</span>
10-
</igx-drop-down-item>
11-
</igx-drop-down>
12-
13-
<igx-input-group
14-
#inputGroupConditions
15-
(click)="toggleCustomDialogDropDown()"
16-
type="box"
17-
[displayDensity]="displayDensity">
18-
1+
<igx-select #dropdownConditions
2+
type="box"
3+
[displayDensity]="displayDensity"
4+
[placeholder]="conditionsPlaceholder"
5+
(onSelection)="onConditionsChanged($event)"
6+
[overlaySettings]="dropDownOverlaySettings">
197
<igx-prefix>
208
<igx-icon *ngIf="expressionUI.expression.condition" fontSet="filtering-icons" [name]="getIconName()"></igx-icon>
219
<igx-icon *ngIf="!expressionUI.expression.condition">filter_list</igx-icon>
2210
</igx-prefix>
23-
24-
<input
25-
igxInput
26-
(keydown)="onInputConditionsKeyDown($event)"
27-
[igxDropDownItemNavigation]="dropdownConditions"
28-
tabindex="0"
29-
[placeholder]="inputConditionsPlaceholder"
30-
autocomplete="off"
31-
[value]="getConditionName(expressionUI.expression.condition)"
32-
[readonly]="true"
33-
/>
34-
</igx-input-group>
11+
<igx-select-item *ngFor="let condition of conditions" [value]="condition" [selected]="isConditionSelected(condition)">
12+
<igx-icon fontSet="filtering-icons" [name]="getCondition(condition).iconName"></igx-icon>
13+
<span>{{translateCondition(condition)}}</span>
14+
</igx-select-item>
15+
</igx-select>
3516

3617
<igx-input-group #inputGroupValues type="box" [displayDensity]="displayDensity">
3718
<input
@@ -74,3 +55,8 @@
7455
{{ grid.resourceStrings.igx_grid_filter_operator_or }}
7556
</span>
7657
</igx-buttongroup>
58+
59+
<div #overlayOutlet
60+
igxOverlayOutlet
61+
(pointerdown)="onOutletPointerDown($event)">
62+
</div>

projects/igniteui-angular/src/lib/grids/filtering/excel-style/excel-style-default-expression.component.ts

+36-53
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import {
1111
import { IgxColumnComponent } from '../../columns/column.component';
1212
import { ExpressionUI } from '../grid-filtering.service';
1313
import { IgxButtonGroupComponent } from '../../../buttonGroup/buttonGroup.component';
14-
import { IgxDropDownItemComponent, IgxDropDownComponent } from '../../../drop-down/public_api';
15-
import { IgxInputGroupComponent, IgxInputDirective } from '../../../input-group/public_api';
1614
import { DataType, DataUtil } from '../../../data-operations/data-util';
1715
import { IFilteringOperation } from '../../../data-operations/filtering-condition';
18-
import { OverlaySettings, ConnectedPositioningStrategy, CloseScrollStrategy } from '../../../services/public_api';
16+
import { OverlaySettings, ConnectedPositioningStrategy, AbsoluteScrollStrategy } from '../../../services/public_api';
1917
import { KEYS, IBaseEventArgs } from '../../../core/utils';
2018
import { FilteringLogic } from '../../../data-operations/filtering-expression.interface';
2119
import { DisplayDensity } from '../../../core/density';
20+
import { IgxSelectComponent } from '../../../select/select.component';
21+
import { IgxOverlayOutletDirective } from '../../../directives/toggle/toggle.directive';
22+
import { IgxInputDirective } from '../../../input-group/public_api';
2223

2324
/**
2425
* @hidden
@@ -39,11 +40,11 @@ export interface ILogicOperatorChangedArgs extends IBaseEventArgs {
3940
})
4041
export class IgxExcelStyleDefaultExpressionComponent implements AfterViewInit {
4142

42-
private _dropDownOverlaySettings: OverlaySettings = {
43-
closeOnOutsideClick: true,
43+
public dropDownOverlaySettings: OverlaySettings = {
44+
scrollStrategy: new AbsoluteScrollStrategy(),
4445
modal: false,
45-
positionStrategy: new ConnectedPositioningStrategy(),
46-
scrollStrategy: new CloseScrollStrategy()
46+
closeOnOutsideClick: true,
47+
excludePositionTarget: true
4748
};
4849

4950
@Input()
@@ -67,21 +68,17 @@ export class IgxExcelStyleDefaultExpressionComponent implements AfterViewInit {
6768
@Output()
6869
public onLogicOperatorChanged = new EventEmitter<ILogicOperatorChangedArgs>();
6970

70-
@ViewChild('inputGroupConditions', { read: IgxInputGroupComponent, static: true })
71-
protected inputGroupConditions: IgxInputGroupComponent;
72-
73-
@ViewChild('inputValues', { read: IgxInputDirective, static: true })
74-
protected inputValuesDirective: IgxInputDirective;
71+
@ViewChild('overlayOutlet', { read: IgxOverlayOutletDirective, static: true })
72+
public overlayOutlet: IgxOverlayOutletDirective;
7573

76-
@ViewChild('dropdownConditions', { read: IgxDropDownComponent, static: true })
77-
protected dropdownConditions: IgxDropDownComponent;
74+
@ViewChild('dropdownConditions', { read: IgxSelectComponent, static: true })
75+
protected dropdownConditions: IgxSelectComponent;
7876

7977
@ViewChild('logicOperatorButtonGroup', { read: IgxButtonGroupComponent })
8078
protected logicOperatorButtonGroup: IgxButtonGroupComponent;
8179

82-
protected get inputValuesElement() {
83-
return this.inputValuesDirective;
84-
}
80+
@ViewChild('inputValues', { read: IgxInputDirective, static: true })
81+
protected inputValuesDirective: IgxInputDirective;
8582

8683
get isLast(): boolean {
8784
return this.expressionsList[this.expressionsList.length - 1] === this.expressionUI;
@@ -91,7 +88,7 @@ export class IgxExcelStyleDefaultExpressionComponent implements AfterViewInit {
9188
return this.expressionsList.length === 1;
9289
}
9390

94-
get inputConditionsPlaceholder(): string {
91+
get conditionsPlaceholder(): string {
9592
return this.grid.resourceStrings['igx_grid_filter_condition_placeholder'];
9693
}
9794

@@ -110,9 +107,19 @@ export class IgxExcelStyleDefaultExpressionComponent implements AfterViewInit {
110107

111108
constructor(public cdr: ChangeDetectorRef) {}
112109

110+
get conditions() {
111+
return this.column.filters.conditionList();
112+
}
113+
114+
protected get inputValuesElement() {
115+
return this.inputValuesDirective;
116+
}
117+
113118
ngAfterViewInit(): void {
114-
this._dropDownOverlaySettings.outlet = this.column.grid.outletDirective;
115-
this._dropDownOverlaySettings.positionStrategy.settings.target = this.inputGroupConditions.element.nativeElement;
119+
this.dropDownOverlaySettings.outlet = this.overlayOutlet;
120+
this.dropDownOverlaySettings.positionStrategy = new ConnectedPositioningStrategy({
121+
target : this.dropdownConditions.inputGroup.element.nativeElement
122+
});
116123
}
117124

118125
public focus() {
@@ -121,22 +128,6 @@ export class IgxExcelStyleDefaultExpressionComponent implements AfterViewInit {
121128
requestAnimationFrame(() => this.inputValuesElement.focus());
122129
}
123130

124-
public isConditionSelected(conditionName: string): boolean {
125-
return this.expressionUI.expression.condition && this.expressionUI.expression.condition.name === conditionName;
126-
}
127-
128-
public getConditionName(condition: IFilteringOperation) {
129-
return condition ? this.translateCondition(condition.name) : null;
130-
}
131-
132-
public getInputWidth() {
133-
return this.inputGroupConditions.element.nativeElement.offsetWidth + 'px';
134-
}
135-
136-
get conditions() {
137-
return this.column.filters.conditionList();
138-
}
139-
140131
public translateCondition(value: string): string {
141132
return this.grid.resourceStrings[`igx_grid_filter_${this.getCondition(value).name}`] || value;
142133
}
@@ -151,21 +142,21 @@ export class IgxExcelStyleDefaultExpressionComponent implements AfterViewInit {
151142
}
152143
}
153144

154-
public toggleCustomDialogDropDown() {
155-
this.dropdownConditions.toggle(this._dropDownOverlaySettings);
156-
}
157-
158-
public getCondition(value: string): IFilteringOperation {
159-
return this.column.filters.condition(value);
145+
public isConditionSelected(conditionName: string): boolean {
146+
return this.expressionUI.expression.condition && this.expressionUI.expression.condition.name === conditionName;
160147
}
161148

162149
public onConditionsChanged(eventArgs: any) {
163-
const value = (eventArgs.newSelection as IgxDropDownItemComponent).value;
150+
const value = (eventArgs.newSelection as IgxSelectComponent).value;
164151
this.expressionUI.expression.condition = this.getCondition(value);
165152

166153
this.focus();
167154
}
168155

156+
public getCondition(value: string): IFilteringOperation {
157+
return this.column.filters.condition(value);
158+
}
159+
169160
public onValuesInput(eventArgs) {
170161
this.expressionUI.expression.searchVal = DataUtil.parseValue(this.column.dataType, eventArgs.target.value);
171162
}
@@ -196,15 +187,7 @@ export class IgxExcelStyleDefaultExpressionComponent implements AfterViewInit {
196187
this.onExpressionRemoved.emit(this.expressionUI);
197188
}
198189

199-
public onInputConditionsKeyDown(eventArgs) {
200-
if (eventArgs.altKey && (eventArgs.key === KEYS.DOWN_ARROW || eventArgs.key === KEYS.DOWN_ARROW_IE)) {
201-
this.toggleCustomDialogDropDown();
202-
}
203-
204-
if (eventArgs.key === KEYS.TAB && eventArgs.shiftKey && this.expressionsList[0] === this.expressionUI) {
205-
eventArgs.preventDefault();
206-
}
207-
208-
eventArgs.stopPropagation();
190+
public onOutletPointerDown(event) {
191+
event.preventDefault();
209192
}
210193
}

projects/igniteui-angular/src/lib/grids/filtering/excel-style/grid.excel-style-filtering.module.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { IgxToggleModule } from '../../../directives/toggle/toggle.directive';
3232
import { IgxListModule } from '../../../list/list.component';
3333
import { IgxExcelStyleSearchFilterPipe } from './excel-style-search.pipe';
3434
import { IgxProgressBarModule } from '../../../progressbar/progressbar.component';
35+
import { IgxSelectModule } from './../../../select/select.module';
3536

3637
/**
3738
* @hidden
@@ -79,7 +80,8 @@ import { IgxProgressBarModule } from '../../../progressbar/progressbar.component
7980
IgxFilterModule,
8081
IgxToggleModule,
8182
IgxListModule,
82-
IgxProgressBarModule
83+
IgxProgressBarModule,
84+
IgxSelectModule,
8385
],
8486
entryComponents: [
8587
IgxGridExcelStyleFilteringComponent

0 commit comments

Comments
 (0)