diff --git a/src/lib/calendar/calendar-foundation.ts b/src/lib/calendar/calendar-foundation.ts index 91f476560..96cfe42e9 100644 --- a/src/lib/calendar/calendar-foundation.ts +++ b/src/lib/calendar/calendar-foundation.ts @@ -1625,7 +1625,8 @@ export class CalendarFoundation implements ICalendarFoundation { private _applyMax(): void { this._adapter.toggleHostAttribute(CALENDAR_CONSTANTS.attributes.MAX, !!this._maxAttribute, this._maxAttribute as string); - if (this._max && this._max.getMonth() < this._month) { + if (this._max && (this._max.getMonth() < this._month || this._max.getFullYear() < this._year)) { + this._year = this._max.getFullYear(); this._month = this._max.getMonth(); } diff --git a/src/test/spec/date-picker/date-picker.spec.ts b/src/test/spec/date-picker/date-picker.spec.ts index 6c304d2f4..70db369ff 100644 --- a/src/test/spec/date-picker/date-picker.spec.ts +++ b/src/test/spec/date-picker/date-picker.spec.ts @@ -99,8 +99,9 @@ describe('DatePickerComponent', function(this: ITestContext) { openPopup(this.context.component); const calendar = getCalendar(this.context.component); + const expectedMonth = date.getMonth() <= 0 ? 11 : date.getMonth() - 1; - expect(calendar.month).toEqual(date.getMonth() - 1); + expect(calendar.month).toEqual(expectedMonth); }); it('should automatically render a toggle button with a Forge text-field component', function(this: ITestContext) {