@@ -1383,6 +1383,27 @@ QUnit.module('Preserve time component on value change', {
1383
1383
1384
1384
assert . deepEqual ( calendar . option ( 'value' ) , new Date ( 2015 , 8 , 2 , 12 , 57 ) ) ;
1385
1385
} ) ;
1386
+
1387
+ QUnit . test ( 'should switch to the last date after setting option programmatically (T1279950)' , function ( assert ) {
1388
+ this . calendar . option ( {
1389
+ selectionMode : 'multiple' ,
1390
+ value : [ new Date ( 2025 , 1 , 10 ) , new Date ( 2025 , 2 , 10 ) ] ,
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 , 2 , 10 ) , 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
+ } ) ;
1386
1407
} ) ;
1387
1408
1388
1409
@@ -2015,15 +2036,15 @@ QUnit.module('Options', {
2015
2036
2016
2037
[
2017
2038
{
2018
- value : [ new Date ( '01/05/ 2023' ) , new Date ( '02/01 /2023' ) ] ,
2039
+ value : [ new Date ( '02/ 01/2023' ) , new Date ( '01/05 /2023' ) ] ,
2019
2040
type : 'dates'
2020
2041
} ,
2021
2042
{
2022
- value : [ '01/05/ 2023' , '02/01 /2023' ] ,
2043
+ value : [ '02/ 01/2023' , '01/05 /2023' ] ,
2023
2044
type : 'strings'
2024
2045
} ,
2025
2046
{
2026
- value : [ 1672916400000 , 1675249200000 ] ,
2047
+ value : [ 1675249200000 , 1672916400000 ] ,
2027
2048
type : 'numbers'
2028
2049
}
2029
2050
] . forEach ( ( { value, type } ) => {
@@ -2040,14 +2061,23 @@ QUnit.module('Options', {
2040
2061
} ) ;
2041
2062
2042
2063
QUnit . module ( 'CurrentDate' , { } , ( ) => {
2043
- QUnit . test ( `Should be equal to the lowest defined date in value on init (selectionMode=${ selectionMode } ` , function ( assert ) {
2064
+ const isMultipleMode = selectionMode === 'multiple' ;
2065
+ const currentDateRule = isMultipleMode ? 'latest entered' : 'lowest defined' ;
2066
+
2067
+ QUnit . test ( `Should be equal to the ${ currentDateRule } date in value on init (selectionMode=${ selectionMode } ` , function ( assert ) {
2068
+ const initialValue = [ null , new Date ( '01/15/2023' ) , new Date ( '02/01/2023' ) ] ;
2069
+
2044
2070
this . reinit ( {
2045
- value : [ null , new Date ( '01/15/2023' ) , new Date ( '02/01/2023' ) ] ,
2071
+ value : initialValue ,
2046
2072
selectionMode
2047
2073
} ) ;
2048
2074
const { currentDate, value } = this . calendar . option ( ) ;
2049
2075
2050
- assert . deepEqual ( currentDate , new Date ( Math . min ( ...value . filter ( value => value ) ) ) ) ;
2076
+ if ( isMultipleMode ) {
2077
+ assert . deepEqual ( currentDate , initialValue [ initialValue . length - 1 ] ) ;
2078
+ } else {
2079
+ assert . deepEqual ( currentDate , new Date ( Math . min ( ...value . filter ( value => value ) ) ) ) ;
2080
+ }
2051
2081
} ) ;
2052
2082
2053
2083
QUnit . test ( `Should be equal to the lowest date in value on runtime value change (selectionMode=${ selectionMode } ` , function ( assert ) {
@@ -2106,7 +2136,7 @@ QUnit.module('Options', {
2106
2136
} ) ;
2107
2137
2108
2138
QUnit . test ( 'It should be possible to deselect already selected value by click' , function ( assert ) {
2109
- const $cell = $ ( getCurrentViewInstance ( this . calendar ) . $element ( ) . find ( '*[data-value="2023/01/15 "]' ) ) ;
2139
+ const $cell = $ ( getCurrentViewInstance ( this . calendar ) . $element ( ) . find ( '*[data-value="2023/02/01 "]' ) ) ;
2110
2140
2111
2141
$cell . trigger ( 'dxclick' ) ;
2112
2142
0 commit comments