Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/components/calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,21 @@ export default class IgcCalendarComponent extends EventEmitterMixin<
}

/** @private @hidden @internal */
public async [focusActiveDate]() {
public async [focusActiveDate](options?: FocusOptions) {
await this.updateComplete;

if (this._isDayView) {
return this.daysViews.item(this.activeDaysViewIndex).focusActiveDate();
return this.daysViews
.item(this.activeDaysViewIndex)
.focusActiveDate(options);
}

if (this._isMonthView) {
return this.monthsView.focusActiveDate();
return this.monthsView.focusActiveDate(options);
}

if (this._isYearView) {
return this.yearsView.focusActiveDate();
return this.yearsView.focusActiveDate(options);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/calendar/days-view/days-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ export default class IgcDaysViewComponent extends EventEmitterMixin<
}

/** Focuses the active date. */
public focusActiveDate() {
this.activeDay.focus();
public focusActiveDate(options?: FocusOptions) {
this.activeDay.focus(options);
}

protected handleInteraction(event: Event) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/calendar/months-view/months-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export default class IgcMonthsViewComponent extends EventEmitterMixin<
}

/** Focuses the active date. */
public focusActiveDate() {
this.activeMonth.focus();
public focusActiveDate(options?: FocusOptions) {
this.activeMonth.focus(options);
}

protected handleInteraction(event: Event) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/calendar/years-view/years-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export default class IgcYearsViewComponent extends EventEmitterMixin<
this.role = 'grid';
}

public focusActiveDate() {
this.activeYear.focus();
public focusActiveDate(options?: FocusOptions) {
this.activeYear.focus(options);
}

protected handleInteraction(event: Event) {
Expand Down
17 changes: 14 additions & 3 deletions src/components/date-range-picker/date-range-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,11 +763,10 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
}

protected override async handleAnchorClick() {
this._calendar.activeDate =
this._firstDefinedInRange ?? this._calendar.activeDate;
super.handleAnchorClick();
this._setCalendarActiveDateAndViewIndex();
await this.updateComplete;
this._calendar[focusActiveDate]();
this._calendar[focusActiveDate]({ preventScroll: true });
}

protected async _handleCalendarChangeEvent(event: CustomEvent<Date>) {
Expand Down Expand Up @@ -806,6 +805,18 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
this.value = this._oldValue;
}

/**
* Sets the active date of the calendar based on current selection, if any,
* or its current active date and its active day view index to always be the first one.
*/
private _setCalendarActiveDateAndViewIndex() {
const activeDaysViewIndex = 'activeDaysViewIndex';

this._calendar.activeDate =
this._firstDefinedInRange ?? this._calendar.activeDate;
this._calendar[activeDaysViewIndex] = 0;
}

private _getUpdatedDateRange(
input: IgcDateTimeInputComponent,
newValue: Date | null
Expand Down