File tree Expand file tree Collapse file tree 5 files changed +26
-13
lines changed
Expand file tree Collapse file tree 5 files changed +26
-13
lines changed Original file line number Diff line number Diff line change @@ -253,19 +253,21 @@ export default class IgcCalendarComponent extends EventEmitterMixin<
253253 }
254254
255255 /** @private @hidden @internal */
256- public async [ focusActiveDate ] ( ) {
256+ public async [ focusActiveDate ] ( options ?: FocusOptions ) {
257257 await this . updateComplete ;
258258
259259 if ( this . _isDayView ) {
260- return this . daysViews . item ( this . activeDaysViewIndex ) . focusActiveDate ( ) ;
260+ return this . daysViews
261+ . item ( this . activeDaysViewIndex )
262+ . focusActiveDate ( options ) ;
261263 }
262264
263265 if ( this . _isMonthView ) {
264- return this . monthsView . focusActiveDate ( ) ;
266+ return this . monthsView . focusActiveDate ( options ) ;
265267 }
266268
267269 if ( this . _isYearView ) {
268- return this . yearsView . focusActiveDate ( ) ;
270+ return this . yearsView . focusActiveDate ( options ) ;
269271 }
270272 }
271273
Original file line number Diff line number Diff line change @@ -147,8 +147,8 @@ export default class IgcDaysViewComponent extends EventEmitterMixin<
147147 }
148148
149149 /** Focuses the active date. */
150- public focusActiveDate ( ) {
151- this . activeDay . focus ( ) ;
150+ public focusActiveDate ( options ?: FocusOptions ) {
151+ this . activeDay . focus ( options ) ;
152152 }
153153
154154 protected handleInteraction ( event : Event ) {
Original file line number Diff line number Diff line change @@ -99,8 +99,8 @@ export default class IgcMonthsViewComponent extends EventEmitterMixin<
9999 }
100100
101101 /** Focuses the active date. */
102- public focusActiveDate ( ) {
103- this . activeMonth . focus ( ) ;
102+ public focusActiveDate ( options ?: FocusOptions ) {
103+ this . activeMonth . focus ( options ) ;
104104 }
105105
106106 protected handleInteraction ( event : Event ) {
Original file line number Diff line number Diff line change @@ -79,8 +79,8 @@ export default class IgcYearsViewComponent extends EventEmitterMixin<
7979 this . role = 'grid' ;
8080 }
8181
82- public focusActiveDate ( ) {
83- this . activeYear . focus ( ) ;
82+ public focusActiveDate ( options ?: FocusOptions ) {
83+ this . activeYear . focus ( options ) ;
8484 }
8585
8686 protected handleInteraction ( event : Event ) {
Original file line number Diff line number Diff line change @@ -763,11 +763,10 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
763763 }
764764
765765 protected override async handleAnchorClick ( ) {
766- this . _calendar . activeDate =
767- this . _firstDefinedInRange ?? this . _calendar . activeDate ;
768766 super . handleAnchorClick ( ) ;
767+ this . _setCalendarActiveDateAndViewIndex ( ) ;
769768 await this . updateComplete ;
770- this . _calendar [ focusActiveDate ] ( ) ;
769+ this . _calendar [ focusActiveDate ] ( { preventScroll : true } ) ;
771770 }
772771
773772 protected async _handleCalendarChangeEvent ( event : CustomEvent < Date > ) {
@@ -806,6 +805,18 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
806805 this . value = this . _oldValue ;
807806 }
808807
808+ /**
809+ * Sets the active date of the calendar based on current selection, if any,
810+ * or its current active date and its active day view index to always be the first one.
811+ */
812+ private _setCalendarActiveDateAndViewIndex ( ) {
813+ const activeDaysViewIndex = 'activeDaysViewIndex' ;
814+
815+ this . _calendar . activeDate =
816+ this . _firstDefinedInRange ?? this . _calendar . activeDate ;
817+ this . _calendar [ activeDaysViewIndex ] = 0 ;
818+ }
819+
809820 private _getUpdatedDateRange (
810821 input : IgcDateTimeInputComponent ,
811822 newValue : Date | null
You can’t perform that action at this time.
0 commit comments