@@ -414,7 +414,7 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
414
414
mode : this . mode ,
415
415
specialDates : this . specialDates ,
416
416
value : this . value ,
417
- openDialog : ( target ?: HTMLElement ) => this . openDialog ( target )
417
+ openDialog : ( ) => this . openDialog ( )
418
418
} ;
419
419
}
420
420
@@ -665,6 +665,9 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
665
665
@ViewChild ( IgxInputGroupComponent )
666
666
protected inputGroup : IgxInputGroupComponent ;
667
667
668
+ @ContentChild ( IgxInputGroupComponent )
669
+ protected inputGroupUserTemplate : IgxInputGroupComponent ;
670
+
668
671
@ViewChild ( IgxInputDirective , { read : ElementRef } )
669
672
private _inputElementRef : ElementRef ;
670
673
@@ -784,7 +787,7 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
784
787
@HostListener ( 'keydown.spacebar' , [ '$event' ] )
785
788
@HostListener ( 'keydown.space' , [ '$event' ] )
786
789
public onSpaceClick ( event : KeyboardEvent ) {
787
- this . openDialog ( this . getInputGroupElement ( ) ) ;
790
+ this . openDialog ( ) ;
788
791
event . preventDefault ( ) ;
789
792
}
790
793
@@ -799,7 +802,13 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
799
802
* @hidden @internal
800
803
*/
801
804
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 ;
803
812
}
804
813
805
814
/**
@@ -983,10 +992,11 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
983
992
* this.datePicker.openDialog(target);
984
993
* ```
985
994
*/
986
- public openDialog ( target ?: HTMLElement ) : void {
995
+ public openDialog ( ) : void {
987
996
if ( ! this . collapsed ) {
988
997
return ;
989
998
}
999
+
990
1000
switch ( this . mode ) {
991
1001
case InteractionMode . Dialog : {
992
1002
this . hasHeader = true ;
@@ -997,6 +1007,7 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
997
1007
}
998
1008
case InteractionMode . DropDown : {
999
1009
this . hasHeader = false ;
1010
+ const target = this . getInputGroupElement ( ) ;
1000
1011
if ( target ) {
1001
1012
this . dropDownOverlaySettings . positionStrategy . settings . target = target ;
1002
1013
}
@@ -1008,14 +1019,6 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
1008
1019
}
1009
1020
}
1010
1021
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
-
1019
1022
/**
1020
1023
* Close the calendar.
1021
1024
*
@@ -1061,6 +1064,12 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
1061
1064
this . onSelection . emit ( date ) ;
1062
1065
}
1063
1066
1067
+ /** @hidden @internal */
1068
+ public onOpenClick ( event : MouseEvent ) {
1069
+ event . stopPropagation ( ) ;
1070
+ this . openDialog ( ) ;
1071
+ }
1072
+
1064
1073
/**
1065
1074
* @hidden @internal
1066
1075
*/
@@ -1099,7 +1108,7 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
1099
1108
case KEYS . DOWN_ARROW :
1100
1109
case KEYS . DOWN_ARROW_IE :
1101
1110
if ( event . altKey ) {
1102
- this . openDialog ( this . getInputGroupElement ( ) ) ;
1111
+ this . openDialog ( ) ;
1103
1112
} else {
1104
1113
event . preventDefault ( ) ;
1105
1114
event . stopPropagation ( ) ;
0 commit comments