@@ -76,7 +76,7 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements Do
7676 }
7777
7878 public get activeDate ( ) {
79- return this . _activeDate ;
79+ return this . _activeDate ? this . _activeDate : this . viewDate . toLocaleDateString ( ) ;
8080 }
8181
8282 /**
@@ -97,6 +97,12 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements Do
9797 @Output ( )
9898 public activeDateChange = new EventEmitter < string > ( ) ;
9999
100+ /**
101+ * @hidden
102+ */
103+ @Output ( )
104+ public monthsViewBlur = new EventEmitter < any > ( ) ;
105+
100106 /**
101107 * @hidden
102108 */
@@ -118,6 +124,7 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements Do
118124 */
119125 public prevMonthView : IgxDaysViewComponent ;
120126 public _activeDate ;
127+ private shouldResetDate = true ;
121128
122129 /**
123130 * The default css class applied to the component.
@@ -127,6 +134,34 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements Do
127134 @HostBinding ( 'class.igx-calendar' )
128135 public styleClass = true ;
129136
137+ /**
138+ * @hidden
139+ * @internal
140+ */
141+ @HostListener ( 'focusout' )
142+ public resetActiveMonth ( ) {
143+ if ( this . shouldResetDate ) {
144+ const date = this . dates . find ( day => day . selected && day . isCurrentMonth )
145+ || this . dates . find ( day => day . isToday && day . isCurrentMonth ) || this . dates . find ( d => d . isFocusable ) ;
146+ if ( date ) { this . activeDate = date . date . date . toLocaleDateString ( ) ; }
147+ this . monthsViewBlur . emit ( ) ;
148+ }
149+ this . shouldResetDate = true ;
150+ }
151+
152+ /**
153+ * @hidden
154+ * @internal
155+ */
156+ @HostListener ( 'keydown.pagedown' )
157+ @HostListener ( 'keydown.pageup' )
158+ @HostListener ( 'keydown.shift.pagedown' )
159+ @HostListener ( 'keydown.shift.pageup' )
160+ @HostListener ( 'pointerdown' )
161+ public pointerDown ( ) {
162+ this . shouldResetDate = false ;
163+ }
164+
130165 /**
131166 * @hidden
132167 */
@@ -389,6 +424,7 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements Do
389424 public onKeydownArrow ( event : KeyboardEvent ) {
390425 event . preventDefault ( ) ;
391426 event . stopPropagation ( ) ;
427+ this . shouldResetDate = false ;
392428 this . daysNavService . focusNextDate ( event . target as HTMLElement , event . key ) ;
393429 }
394430
@@ -399,6 +435,7 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements Do
399435 public onKeydownHome ( event : KeyboardEvent ) {
400436 event . preventDefault ( ) ;
401437 event . stopPropagation ( ) ;
438+ this . shouldResetDate = false ;
402439 this . getFirstMonthView ( ) . daysNavService . focusHomeDate ( ) ;
403440 }
404441
@@ -409,6 +446,7 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements Do
409446 public onKeydownEnd ( event : KeyboardEvent ) {
410447 event . preventDefault ( ) ;
411448 event . stopPropagation ( ) ;
449+ this . shouldResetDate = false ;
412450 this . getLastMonthView ( ) . daysNavService . focusEndDate ( ) ;
413451 }
414452}
0 commit comments