File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed
Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change 306306 if ( e . ctrlKey ) { return true ; }
307307 var key = e . keyCode ;
308308
309- // backspace clears the value
310- if ( key == 8 ) {
309+ // backspace or delete clears the value
310+ if ( key == 8 || key == 9 ) {
311311 input . val ( "" ) ;
312312 return self . hide ( e ) ;
313313 }
314314
315- // esc key
316- if ( key == 27 ) { return self . hide ( e ) ; }
315+ // esc or tab key exits
316+ if ( key == 27 || key == 9 ) { return self . hide ( e ) ; }
317317
318318 if ( $ ( KEYS ) . index ( key ) >= 0 ) {
319319
634634 e . type = "onHide" ;
635635 fire . trigger ( e ) ;
636636
637- $ ( document ) . unbind ( "click.d" ) . unbind ( "keydown.d" ) ;
638-
639637 // cancelled ?
640638 if ( e . isDefaultPrevented ( ) ) { return ; }
641639
640+ $ ( document ) . unbind ( "click.d" ) . unbind ( "keydown.d" ) ;
641+ input . focus ( ) ;
642+ input . select ( ) ;
643+
642644 // do the hide
643645 root . hide ( ) ;
644646 opened = false ;
690692
691693 var key = e . keyCode ;
692694
693- // open dateinput with navigation keyw
695+ // open dateinput with navigation keys, or clear value on backspace or delete
694696 if ( ! opened && $ ( KEYS ) . index ( key ) >= 0 ) {
695697 self . show ( e ) ;
696698 return e . preventDefault ( ) ;
697- }
699+ } else if ( key == 8 || key == 46 ) {
700+ input . val ( "" ) ;
701+ }
698702
699703 // allow tab
700704 return e . shiftKey || e . ctrlKey || e . altKey || key == 9 ? true : e . preventDefault ( ) ;
701705
702- } ) ;
703-
704- // hide when focus is lost
705- input . bind ( "blur" , self . hide ) ;
706-
706+ } ) ;
707+
707708 // initial value
708709 if ( parseDate ( input . val ( ) ) ) {
709710 select ( value , conf ) ;
You can’t perform that action at this time.
0 commit comments