@@ -72,10 +72,12 @@ class ListStrategy extends DateBoxStrategy {
7272
7373 if ( selectedIndex === - 1 ) {
7474 const { value } = this . dateBox . option ( ) ;
75+
7576 return value as Date ;
7677 }
7778
7879 const itemData = this . _widgetItems [ selectedIndex ] ;
80+
7981 return this . _getDateByItemData ( itemData ) ;
8082 }
8183
@@ -103,12 +105,12 @@ class ListStrategy extends DateBoxStrategy {
103105 _getWidgetOptions ( ) : Record < string , unknown > {
104106 return {
105107 itemTemplate : this . _timeListItemTemplate . bind ( this ) ,
106- onItemClick : this . _listItemClickHandler . bind ( this ) ,
108+ selectionMode : 'single' ,
107109 tabIndex : - 1 ,
110+ onItemClick : this . _listItemClickHandler . bind ( this ) ,
108111 onFocusedItemChanged : (
109112 e : DxEvent & { actionValue : string } ,
110113 ) => this . _refreshActiveDescendant ( e ) ,
111- selectionMode : 'single' ,
112114 } ;
113115 }
114116
@@ -128,9 +130,10 @@ class ListStrategy extends DateBoxStrategy {
128130 }
129131
130132 this . _widget . option ( 'focusedElement' , null ) ;
131-
132133 this . _setSelectedItemsByValue ( ) ;
134+
133135 const { templatesRenderAsynchronously } = this . getWidget ( ) . option ( ) ;
136+
134137 if ( templatesRenderAsynchronously ) {
135138 // eslint-disable-next-line no-restricted-globals
136139 this . _asyncScrollTimeout = setTimeout ( this . _scrollToSelectedItem . bind ( this ) ) ;
@@ -141,18 +144,27 @@ class ListStrategy extends DateBoxStrategy {
141144
142145 dispose ( ) : void {
143146 super . dispose ( ) ;
147+
144148 clearTimeout ( this . _asyncScrollTimeout ) ;
145149 }
146150
151+ renderValue ( ) : void {
152+ this . _updateValue ( ) ;
153+ }
154+
147155 _updateValue ( ) : void {
148156 if ( ! this . _widget ) {
149157 return ;
150158 }
151159
152160 this . _refreshItems ( ) ;
153161
154- this . _setSelectedItemsByValue ( ) ;
155- this . _scrollToSelectedItem ( ) ;
162+ const { opened } = this . dateBox . option ( ) ;
163+
164+ if ( opened ) {
165+ this . _setSelectedItemsByValue ( ) ;
166+ this . _scrollToSelectedItem ( ) ;
167+ }
156168 }
157169
158170 _setSelectedItemsByValue ( ) : void {
@@ -192,10 +204,13 @@ class ListStrategy extends DateBoxStrategy {
192204
193205 _getTimeListItems ( ) : Date [ ] {
194206 let min = this . dateBox . getDateOption ( 'min' ) ?? this . _getBoundaryDate ( 'min' ) ;
207+
195208 const max = this . dateBox . getDateOption ( 'max' ) ?? this . _getBoundaryDate ( 'max' ) ;
196209 const value = this . dateBox . getDateOption ( 'value' ) ?? null ;
210+
197211 // @ts -expect-error ts-error
198212 let delta = max - min ;
213+
199214 const { interval = 30 } = this . dateBox . option ( ) ;
200215 const minutes = min . getMinutes ( ) % interval ;
201216
@@ -206,6 +221,7 @@ class ListStrategy extends DateBoxStrategy {
206221 if ( delta > dateUtils . ONE_DAY ) {
207222 delta = dateUtils . ONE_DAY ;
208223 }
224+
209225 // @ts -expect-error ts-error
210226 if ( value - min < dateUtils . ONE_DAY ) {
211227 return this . _getRangeItems ( min , new Date ( min ) , delta ) ;
@@ -237,7 +253,11 @@ class ListStrategy extends DateBoxStrategy {
237253
238254 _getBoundaryDate ( boundary : 'min' | 'max' ) : Date {
239255 const boundaryValue = BOUNDARY_VALUES [ boundary ] ;
240- const currentValue = new Date ( ensureDefined ( this . dateBox . getDateOption ( 'value' ) , new Date ( 0 ) ) ) ;
256+ const dateBoxDate = this . dateBox . getDateOption ( 'value' ) ;
257+ const newDate = new Date ( 0 ) ;
258+ const definedValue = ensureDefined ( dateBoxDate , newDate ) ;
259+
260+ const currentValue = new Date ( definedValue ) ;
241261
242262 return new Date (
243263 currentValue . getFullYear ( ) ,
@@ -267,6 +287,7 @@ class ListStrategy extends DateBoxStrategy {
267287
268288 _getDateByItemData ( itemData : Date ) : Date {
269289 let { value : date } = this . dateBox . option ( ) ;
290+
270291 const hours = itemData . getHours ( ) ;
271292 const minutes = itemData . getMinutes ( ) ;
272293 const seconds = itemData . getSeconds ( ) ;
@@ -276,6 +297,7 @@ class ListStrategy extends DateBoxStrategy {
276297
277298 if ( date ) {
278299 const { dateSerializationFormat } = this . dateBox . option ( ) ;
300+
279301 if ( dateSerializationFormat ) {
280302 date = dateSerialization . deserializeDate ( date ) as Date ;
281303 } else {
@@ -301,10 +323,13 @@ class ListStrategy extends DateBoxStrategy {
301323
302324 _updatePopupHeight ( ) : void {
303325 const dropDownOptionsHeight = getSizeValue ( this . dateBox . option ( 'dropDownOptions.height' ) ) ;
326+
304327 if ( dropDownOptionsHeight === undefined || dropDownOptionsHeight === 'auto' ) {
305328 this . dateBox . _setPopupOption ( 'height' , 'auto' ) ;
329+
306330 const popupHeight = getOuterHeight ( this . getWidget ( ) . $element ( ) ) ;
307331 const maxHeight = getHeight ( window ) * 0.45 ;
332+
308333 this . dateBox . _setPopupOption ( 'height' , Math . min ( popupHeight , maxHeight ) ) ;
309334 }
310335 }
0 commit comments