Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kit): CalendarRange defaultViewedMonth shows correct calendars months #8400

Merged
merged 1 commit into from
Aug 13, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ export class TuiCalendarRangeComponent implements TuiWithOptionalMinMax<TuiDay>
this.value = this.previousValue;
}

readonly monthOffset: TuiTypedMapper<[TuiMonth, number], TuiMonth> = (value, month) =>
value.append({month});

readonly mapper: TuiTypedMapper<
[
readonly TuiDayRangePeriod[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
automation-id="tui-calendar-range__calendars"
tuiPreventDefault="mousedown"
[defaultViewedMonthFirst]="defaultViewedMonth"
[defaultViewedMonthSecond]="defaultViewedMonth | tuiMapper: monthOffset : 1"
[disabledItemHandler]="calculatedDisabledItemHandler"
[markerHandler]="markerHandler"
[max]="computedMax | tuiMapper: maxLengthMapper : value : maxLength : false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ describe('PrimitiveRangeCalendar component', () => {
component.ngOnInit();
expect(component.userViewedMonthFirst).toEqual(minDate);
});

it('When initialized input defaultViewedMonthFirst, shows defaultViewedMonthFirst', () => {
const month = new TuiMonth(2020, 5);

component.defaultViewedMonthFirst = month;
component.ngOnInit();

expect(component.userViewedMonthFirst).toBe(month);
});
});

describe('viewedMonthSecond', () => {
Expand Down Expand Up @@ -105,6 +114,15 @@ describe('PrimitiveRangeCalendar component', () => {

expect(component.userViewedMonthSecond).toEqual(minDate.append({month: 1}));
});

it('When initialized input defaultViewedMonthSecond, shows defaultViewedMonthSecond', () => {
const month = new TuiMonth(2020, 5);

component.defaultViewedMonthSecond = month;
component.ngOnInit();

expect(component.userViewedMonthSecond).toBe(month);
});
});

describe('cappedUserViewedMonthSecond', () => {
Expand Down
Loading