diff --git a/projects/demo-playwright/tests/kit/input-date-range/input-date-range.spec.ts b/projects/demo-playwright/tests/kit/input-date-range/input-date-range.spec.ts index b951be4b9dc8..4903e1029343 100644 --- a/projects/demo-playwright/tests/kit/input-date-range/input-date-range.spec.ts +++ b/projects/demo-playwright/tests/kit/input-date-range/input-date-range.spec.ts @@ -168,6 +168,17 @@ test.describe('InputDateRange', () => { '07-item-and-calendar-interactions.png', ); }); + + test('Calendar shows end of period, when selected any range', async ({page}) => { + await tuiGoto(page, 'components/input-date-range/API?items$=1'); + + await inputDateRange.textfield.click(); + await inputDateRange.selectItem(0); + + await inputDateRange.textfield.click(); + + await expect(example).toHaveScreenshot('09-calendar-shows-end-of-period.png'); + }); }); test.describe('Examples', () => { diff --git a/projects/kit/components/calendar-range/calendar-range.component.ts b/projects/kit/components/calendar-range/calendar-range.component.ts index e34d580f32af..757c6eb3f9f5 100644 --- a/projects/kit/components/calendar-range/calendar-range.component.ts +++ b/projects/kit/components/calendar-range/calendar-range.component.ts @@ -114,7 +114,9 @@ export class TuiCalendarRange implements OnInit, OnChanges { } public ngOnChanges(): void { - this.defaultViewedMonth = this.value?.from || this.defaultViewedMonth; + this.defaultViewedMonth = + (this.items.length ? this.value?.to : this.value?.from) || + this.defaultViewedMonth; } public ngOnInit(): void {