Skip to content

Commit 2c2e89f

Browse files
authored
Merge branch 'master' into SKrastev/grid-disabled-pin-row
2 parents 6d614a0 + d5d41bd commit 2c2e89f

12 files changed

+213
-166
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ All notable changes for each version of this project will be documented in this
1010

1111
- `IgxInputGroup`
1212
- **Renamed** `supressInputAutofocus` input to `suppressInputAutofocus`
13+
- Clicking on prefix, suffix or label elements in the Input Group will no longer blur and re-focus the input.
1314

1415
### Themes
1516
- **Breaking Change** Change the default `$legacy-support` value to false in the `igx-theme` function.

projects/igniteui-angular/src/lib/date-picker/date-picker.component.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<ng-template #readOnlyDatePickerTemplate>
2-
<igx-input-group (click)="openDialog()" (mousedown)="mouseDown($event)">
2+
<igx-input-group (click)="openDialog()">
33
<igx-prefix>
44
<igx-icon>today</igx-icon>
55
</igx-prefix>
@@ -16,8 +16,8 @@
1616
</ng-template>
1717

1818
<ng-template #editableDatePickerTemplate>
19-
<igx-input-group #editableInputGroup [suppressInputAutofocus]="true" (mousedown)="mouseDown($event)">
20-
<igx-prefix (click)="openDialog(editableInputGroup.element.nativeElement)">
19+
<igx-input-group #editableInputGroup>
20+
<igx-prefix (click)="onOpenClick($event)">
2121
<igx-icon>today</igx-icon>
2222
</igx-prefix>
2323
<label *ngIf="labelVisibility" igxLabel>{{label}}</label>

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

+22-13
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
414414
mode: this.mode,
415415
specialDates: this.specialDates,
416416
value: this.value,
417-
openDialog: (target?: HTMLElement) => this.openDialog(target)
417+
openDialog: () => this.openDialog()
418418
};
419419
}
420420

@@ -665,6 +665,9 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
665665
@ViewChild(IgxInputGroupComponent)
666666
protected inputGroup: IgxInputGroupComponent;
667667

668+
@ContentChild(IgxInputGroupComponent)
669+
protected inputGroupUserTemplate: IgxInputGroupComponent;
670+
668671
@ViewChild(IgxInputDirective, { read: ElementRef })
669672
private _inputElementRef: ElementRef;
670673

@@ -784,7 +787,7 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
784787
@HostListener('keydown.spacebar', ['$event'])
785788
@HostListener('keydown.space', ['$event'])
786789
public onSpaceClick(event: KeyboardEvent) {
787-
this.openDialog(this.getInputGroupElement());
790+
this.openDialog();
788791
event.preventDefault();
789792
}
790793

@@ -799,7 +802,13 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
799802
* @hidden @internal
800803
*/
801804
public getInputGroupElement() {
802-
return this.inputGroup ? this.inputGroup.element.nativeElement : null;
805+
if (this.inputGroup) {
806+
return this.inputGroup.element.nativeElement;
807+
}
808+
if (this.inputGroupUserTemplate) {
809+
return this.inputGroupUserTemplate.element.nativeElement;
810+
}
811+
return null;
803812
}
804813

805814
/**
@@ -983,10 +992,11 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
983992
* this.datePicker.openDialog(target);
984993
* ```
985994
*/
986-
public openDialog(target?: HTMLElement): void {
995+
public openDialog(): void {
987996
if (!this.collapsed) {
988997
return;
989998
}
999+
9901000
switch (this.mode) {
9911001
case InteractionMode.Dialog: {
9921002
this.hasHeader = true;
@@ -997,6 +1007,7 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
9971007
}
9981008
case InteractionMode.DropDown: {
9991009
this.hasHeader = false;
1010+
const target = this.getInputGroupElement();
10001011
if (target) {
10011012
this.dropDownOverlaySettings.positionStrategy.settings.target = target;
10021013
}
@@ -1008,14 +1019,6 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
10081019
}
10091020
}
10101021

1011-
public mouseDown(e) {
1012-
// if the click is not on the input but in input group
1013-
// e.g. on prefix or sufix, prevent default and this way prevent blur
1014-
if (e.target !== this.getEditElement()) {
1015-
e.preventDefault();
1016-
}
1017-
}
1018-
10191022
/**
10201023
* Close the calendar.
10211024
*
@@ -1061,6 +1064,12 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
10611064
this.onSelection.emit(date);
10621065
}
10631066

1067+
/** @hidden @internal */
1068+
public onOpenClick(event: MouseEvent) {
1069+
event.stopPropagation();
1070+
this.openDialog();
1071+
}
1072+
10641073
/**
10651074
* @hidden @internal
10661075
*/
@@ -1099,7 +1108,7 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
10991108
case KEYS.DOWN_ARROW:
11001109
case KEYS.DOWN_ARROW_IE:
11011110
if (event.altKey) {
1102-
this.openDialog(this.getInputGroupElement());
1111+
this.openDialog();
11031112
} else {
11041113
event.preventDefault();
11051114
event.stopPropagation();

projects/igniteui-angular/src/lib/grids/filtering/advanced-filtering/advanced-filtering-dialog.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ <h6 class="igx-filter-empty__title">
184184
[locale]="grid.locale"
185185
[outlet]="grid.outletDirective">
186186
<ng-template igxDatePickerTemplate let-openDialog="openDialog" let-value="value">
187-
<igx-input-group #dropDownTarget type="box" [displayDensity]="'compact'" [suppressInputAutofocus]="true">
187+
<igx-input-group #dropDownTarget type="box" [displayDensity]="'compact'">
188188
<input #searchValueInput
189189
igxInput
190190
tabindex="0"

projects/igniteui-angular/src/lib/grids/filtering/base/grid-filtering-row.component.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
</igx-drop-down>
1111

1212
<ng-template #defaultFilterUI>
13-
<igx-input-group #inputGroup type="box" [displayDensity]="'compact'" [suppressInputAutofocus]="true" (focusout)="onInputGroupFocusout()">
13+
<igx-input-group #inputGroup type="box" [displayDensity]="'compact'" (focusout)="onInputGroupFocusout()">
1414
<igx-prefix #inputGroupPrefix
15-
(click)="toggleConditionsDropDown(inputGroupPrefix)"
15+
(click)="inputGroupPrefixClick($event)"
1616
(keydown)="onPrefixKeyDown($event)"
1717
tabindex="0"
1818
[igxDropDownItemNavigation]="inputGroupConditions">
@@ -50,10 +50,10 @@
5050
(onSelection)="onDateSelected($event)"
5151
(onClose)="datePickerClose()">
5252
<ng-template igxDatePickerTemplate let-openDialog="openDialog">
53-
<igx-input-group #inputGroup type="box" [displayDensity]="'compact'" [suppressInputAutofocus]="true" (focusout)="onInputGroupFocusout()">
53+
<igx-input-group #inputGroup type="box" [displayDensity]="'compact'" (focusout)="onInputGroupFocusout()">
5454
<igx-prefix #inputGroupPrefix
5555
tabindex="0"
56-
(click)="toggleConditionsDropDown(inputGroupPrefix)"
56+
(click)="inputGroupPrefixClick($event)"
5757
(keydown)="onPrefixKeyDown($event)"
5858
[igxDropDownItemNavigation]="inputGroupConditions">
5959
<igx-icon fontSet="filtering-icons" [name]="expression.condition.iconName"></igx-icon>

projects/igniteui-angular/src/lib/grids/filtering/base/grid-filtering-row.component.ts

+7
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,13 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
482482
this.value = value;
483483
}
484484

485+
/** @hidden @internal */
486+
public inputGroupPrefixClick(event: MouseEvent) {
487+
event.stopPropagation();
488+
(event.currentTarget as HTMLElement).focus();
489+
this.toggleConditionsDropDown(event.currentTarget);
490+
}
491+
485492
/**
486493
* Opens the conditions dropdown.
487494
*/

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
#inputGroupConditions
1515
(click)="toggleCustomDialogDropDown()"
1616
type="box"
17-
[displayDensity]="displayDensity"
18-
[suppressInputAutofocus]="true">
17+
[displayDensity]="displayDensity">
1918

2019
<igx-prefix>
2120
<igx-icon *ngIf="expressionUI.expression.condition" fontSet="filtering-icons" [name]="getIconName()"></igx-icon>
@@ -36,7 +35,7 @@
3635

3736
<igx-date-picker #datePicker mode="dropdown" [(ngModel)]="expressionUI.expression.searchVal" [locale]="grid.locale" [outlet]="grid.outletDirective">
3837
<ng-template igxDatePickerTemplate let-openDialog="openDialog" let-value="value">
39-
<igx-input-group #dropDownTarget type="box" [displayDensity]="displayDensity" [suppressInputAutofocus]="true">
38+
<igx-input-group #dropDownTarget type="box" [displayDensity]="displayDensity">
4039
<input #input
4140
igxInput
4241
tabindex="0"

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
#inputGroupConditions
1515
(click)="toggleCustomDialogDropDown()"
1616
type="box"
17-
[displayDensity]="displayDensity"
18-
[suppressInputAutofocus]="true">
17+
[displayDensity]="displayDensity">
1918

2019
<igx-prefix>
2120
<igx-icon *ngIf="expressionUI.expression.condition" fontSet="filtering-icons" [name]="getIconName()"></igx-icon>
@@ -34,7 +33,7 @@
3433
/>
3534
</igx-input-group>
3635

37-
<igx-input-group #inputGroupValues type="box" [displayDensity]="displayDensity" [suppressInputAutofocus]="true">
36+
<igx-input-group #inputGroupValues type="box" [displayDensity]="displayDensity">
3837
<input
3938
#inputValues
4039
igxInput

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<igx-input-group
22
type="box"
3-
[displayDensity]="displayDensity"
4-
[suppressInputAutofocus]="true">
3+
[displayDensity]="displayDensity">
54
<igx-icon igxPrefix>search</igx-icon>
65
<input
76
#input

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts

+13-3
Original file line numberDiff line numberDiff line change
@@ -1260,17 +1260,22 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
12601260
GridFunctions.clickFilterCellChip(fix, 'ProductName');
12611261

12621262
const prefix = GridFunctions.getFilterRowPrefix(fix);
1263+
const event = {
1264+
currentTarget: prefix.nativeElement,
1265+
preventDefault: () => {},
1266+
stopPropagation: () => {}
1267+
};
12631268

12641269
// Click prefix to open conditions dropdown
1265-
prefix.triggerEventHandler('click', {});
1270+
prefix.triggerEventHandler('click', event);
12661271
tick(100);
12671272
fix.detectChanges();
12681273

12691274
// Verify dropdown is opened
12701275
GridFunctions.verifyFilteringDropDownIsOpened(fix);
12711276

12721277
// Click prefix again to close conditions dropdown
1273-
prefix.triggerEventHandler('click', {});
1278+
prefix.triggerEventHandler('click', event);
12741279
tick(100);
12751280
fix.detectChanges();
12761281

@@ -1282,9 +1287,14 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
12821287
GridFunctions.clickFilterCellChip(fix, 'ProductName');
12831288

12841289
const prefix = GridFunctions.getFilterRowPrefix(fix);
1290+
const event = {
1291+
currentTarget: prefix.nativeElement,
1292+
preventDefault: () => {},
1293+
stopPropagation: () => {}
1294+
};
12851295

12861296
// Click prefix to open conditions dropdown
1287-
prefix.triggerEventHandler('click', {});
1297+
prefix.triggerEventHandler('click', event);
12881298
tick(100);
12891299
fix.detectChanges();
12901300

0 commit comments

Comments
 (0)