@@ -198,15 +198,35 @@ function attachFlatpickr(node, opts, plugins = opts.noCalendar ? [] : [new yearD
198
198
const fp = flatpickr ( node , {
199
199
...opts ,
200
200
onOpen : [
201
- function ( selectedDates , dateStr , instance ) {
202
- instance . altInput . setAttribute ( 'readonly' , true ) ;
201
+ async function ( selectedDates , dateStr , instance ) {
202
+ if ( instance . altInput ) {
203
+ instance . altInput . setAttribute ( 'readonly' , true ) ;
204
+
205
+ const dayElement = await instance . days ;
206
+ if ( dayElement ) {
207
+ if ( dayElement . querySelector ( '.today' ) ) {
208
+ dayElement . querySelector ( '.today' ) . focus ( ) ;
209
+ } else {
210
+ dayElement . querySelector ( '.selected' ) . focus ( ) ;
211
+ }
212
+ }
213
+ } else {
214
+ instance . input . setAttribute ( 'readonly' , true ) ;
215
+ instance . hourElement . focus ( )
216
+ console . log ( ) ;
217
+ }
203
218
} ,
204
219
...opts . onOpen
205
220
] ,
206
221
onClose : [
207
222
function ( selectedDates , dateStr , instance ) {
208
- instance . altInput . setAttribute ( 'readonly' , false ) ;
209
- instance . altInput . blur ( ) ;
223
+ if ( instance . altInput ) {
224
+ instance . altInput . setAttribute ( 'readonly' , false ) ;
225
+ instance . altInput . blur ( ) ;
226
+ } else {
227
+ instance . input . setAttribute ( 'readonly' , false ) ;
228
+ instance . input . blur ( ) ;
229
+ }
210
230
} ,
211
231
...opts . onClose
212
232
] ,
0 commit comments