Datepicker: Update the picker as the user types valid dates

This commit is contained in:
TJ VanToll 2014-01-03 09:55:06 -05:00 committed by Scott González
parent feedc57486
commit fd215f1863
2 changed files with 12 additions and 1 deletions

View File

@ -218,7 +218,7 @@ asyncTest( "baseStructure", function() {
});
test( "Keyboard handling", function() {
expect( 8 );
expect( 9 );
var input = $( "#datepicker" ).datepicker(),
instance = input.datepicker( "instance" ),
date = new Date();
@ -260,6 +260,11 @@ test( "Keyboard handling", function() {
TestHelpers.datepicker.equalsDate( input.datepicker( "valueAsDate" ), new Date( 2014, 0, 1 ),
"Keystroke esc - abandoned" );
input.val( "1/2/14" )
.simulate( "keyup" );
TestHelpers.datepicker.equalsDate( input.datepicker( "valueAsDate" ), new Date( 2014, 0, 2 ),
"Picker updated as user types into input" );
input.datepicker( "destroy" );
});

View File

@ -232,6 +232,12 @@ $.widget( "ui.datepicker", {
break;
}
},
keyup: function() {
if ( this.isValid() && !this.inline ) {
this.date.setTime( this.element.val() ).select();
this.refresh();
}
},
mousedown: function( event ) {
if (this.isOpen) {
suppressExpandOnFocus = true;