Skip to content

Commit f7c80ba

Browse files
author
Ruslan Farkhutdinov
committed
Calendar: Should switch to the last date view in multiple & controlled mode (T1279950)
1 parent 24a55ba commit f7c80ba

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

packages/devextreme/js/__internal/ui/calendar/m_calendar.multiple.selection.strategy.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class CalendarMultiSelectionStrategy extends CalendarSelectionStrategy {
3939
}
4040

4141
getDefaultCurrentDate() {
42-
const dates = this.dateOption('value').filter((value) => value);
43-
return this._getLowestDateInArray(dates);
42+
const dates = this.dateOption('value').filter(Boolean);
43+
return dates.length ? dates[dates.length - 1] : new Date();
4444
}
4545

4646
restoreValue() {

packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/calendar.tests.js

+21
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,27 @@ QUnit.module('Preserve time component on value change', {
13831383

13841384
assert.deepEqual(calendar.option('value'), new Date(2015, 8, 2, 12, 57));
13851385
});
1386+
1387+
QUnit.test('should switch to the last date after setting option programmatically (T1279950)', function(assert) {
1388+
this.reinit({
1389+
value: [new Date(2025, 1, 10), new Date(2025, 2, 10)],
1390+
selectionMode: 'multiple'
1391+
});
1392+
1393+
const calendar = this.calendar;
1394+
1395+
assert.ok(
1396+
dateUtils.sameMonth(calendar.option('currentDate'), new Date(2025, 2, 10)),
1397+
'initially navigated to the last date'
1398+
);
1399+
1400+
calendar.option('value', [new Date(2025, 4, 10), new Date(2025, 3, 10)]);
1401+
1402+
assert.ok(
1403+
dateUtils.sameMonth(calendar.option('currentDate'), new Date(2025, 3, 10)),
1404+
'switched to the last entered date'
1405+
);
1406+
});
13861407
});
13871408

13881409

0 commit comments

Comments
 (0)