@@ -2205,6 +2205,51 @@ QUnit.module('datebox w/ time list', {
22052205 assert . deepEqual ( this . dateBox . option ( 'value' ) , new Date ( 2020 , 4 , 13 , 1 , 30 ) , 'date is correct' ) ;
22062206 } ) ;
22072207
2208+ QUnit . test ( 'time selection should use updated date after external value change while popup is closed (T1325614)' , function ( assert ) {
2209+ this . dateBox . option ( {
2210+ type : 'time' ,
2211+ pickerType : 'list' ,
2212+ value : new Date ( 1995 , 11 , 25 , 12 , 0 ) ,
2213+ opened : true
2214+ } ) ;
2215+
2216+ const $list = $ ( this . dateBox . content ( ) ) . find ( LIST_ITEM_SELECTOR ) ;
2217+
2218+ $ ( $list . eq ( 3 ) ) . trigger ( 'dxclick' ) ;
2219+
2220+ this . dateBox . option ( 'value' , new Date ( 1995 , 11 , 12 , 12 , 0 ) ) ;
2221+ this . dateBox . open ( ) ;
2222+
2223+ const $updatedList = $ ( this . dateBox . content ( ) ) . find ( LIST_ITEM_SELECTOR ) ;
2224+
2225+ $ ( $updatedList . eq ( 5 ) ) . trigger ( 'dxclick' ) ;
2226+
2227+ const result = this . dateBox . option ( 'value' ) ;
2228+
2229+ assert . strictEqual ( result . getDate ( ) , 12 , 'date part is preserved after time selection' ) ;
2230+ assert . strictEqual ( result . getMonth ( ) , 11 , 'month part is preserved after time selection' ) ;
2231+ assert . strictEqual ( result . getFullYear ( ) , 1995 , 'year part is preserved after time selection' ) ;
2232+ } ) ;
2233+
2234+ QUnit . test ( 'list items should be refreshed after value is changed while popup is closed (T1325614)' , function ( assert ) {
2235+ this . dateBox . option ( {
2236+ type : 'time' ,
2237+ pickerType : 'list' ,
2238+ value : new Date ( 2020 , 4 , 13 , 10 , 0 ) ,
2239+ opened : true
2240+ } ) ;
2241+
2242+ this . dateBox . option ( 'opened' , false ) ;
2243+ this . dateBox . option ( 'value' , new Date ( 2020 , 8 , 20 , 10 , 0 ) ) ;
2244+ this . dateBox . option ( 'opened' , true ) ;
2245+
2246+ const itemData = this . dateBox . _strategy . _widgetItems [ 0 ] ;
2247+
2248+ assert . strictEqual ( itemData . getFullYear ( ) , 2020 , 'item year is updated' ) ;
2249+ assert . strictEqual ( itemData . getMonth ( ) , 8 , 'item month is updated' ) ;
2250+ assert . strictEqual ( itemData . getDate ( ) , 20 , 'item day is updated' ) ;
2251+ } ) ;
2252+
22082253 QUnit . test ( 'the date should be in range after the selection' , function ( assert ) {
22092254 this . dateBox . option ( {
22102255 type : 'time' ,
@@ -2498,12 +2543,13 @@ QUnit.module('datebox w/ time list', {
24982543 dateSerializationFormat : 'yyyy-MM-ddTHH:mm:ssx' ,
24992544 } ) ;
25002545 const $input = $ ( this . dateBox . element ( ) ) . find ( `.${ TEXTEDITOR_INPUT_CLASS } ` ) ;
2501- const $items = $ ( this . dateBox . content ( ) ) . find ( LIST_ITEM_SELECTOR ) ;
2546+ let $items = $ ( this . dateBox . content ( ) ) . find ( LIST_ITEM_SELECTOR ) ;
25022547
25032548 $items . eq ( 1 ) . trigger ( 'dxclick' ) ;
25042549 assert . strictEqual ( $input . val ( ) , $items . eq ( 1 ) . text ( ) , 'time is applied' ) ;
25052550
25062551 this . dateBox . open ( ) ;
2552+ $items = $ ( this . dateBox . content ( ) ) . find ( LIST_ITEM_SELECTOR ) ;
25072553 $items . eq ( 3 ) . trigger ( 'dxclick' ) ;
25082554 assert . strictEqual ( $input . val ( ) , $items . eq ( 3 ) . text ( ) , 'new time is applied' ) ;
25092555 } ) ;
0 commit comments