From 280cda31d053cea55a6aa3547d88ce9994bff286 Mon Sep 17 00:00:00 2001 From: Felix Nagel Date: Wed, 13 Apr 2016 21:54:48 +0200 Subject: [PATCH] Datepicker: Always focus calendar grid when opening Remove arrow down key requirement. --- tests/unit/datepicker/core.js | 4 ++-- ui/widgets/datepicker.js | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/unit/datepicker/core.js b/tests/unit/datepicker/core.js index cfcc9c947..337032075 100644 --- a/tests/unit/datepicker/core.js +++ b/tests/unit/datepicker/core.js @@ -52,9 +52,9 @@ asyncTest( "Keyboard handling: input", function() { ok( !picker.is( ":visible" ), "datepicker closed" ); - input.val( "" ).simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + input.val( "" ).focus(); setTimeout( function() { - ok( picker.is( ":visible" ), "Keystroke down opens datepicker" ); + ok( picker.is( ":visible" ), "Datepicker opens when receiving focus" ); input.datepicker( "destroy" ); step2(); }, 100 ); diff --git a/ui/widgets/datepicker.js b/ui/widgets/datepicker.js index 99f34785f..6d45055e8 100644 --- a/ui/widgets/datepicker.js +++ b/ui/widgets/datepicker.js @@ -140,13 +140,10 @@ var widget = $.widget( "ui.datepicker", { this.close( event ); } break; + case $.ui.keyCode.ENTER: case $.ui.keyCode.DOWN: case $.ui.keyCode.UP: - clearTimeout( this.closeTimer ); - this._delay( function() { - this.open( event ); - this.calendarInstance.grid.focus(); - }, 1 ); + this.open( event ); break; } }, @@ -279,6 +276,10 @@ var widget = $.widget( "ui.datepicker", { this.isOpen = true; this._trigger( "open", event ); + + this._delay( function() { + this.calendarInstance.grid.focus(); + } ); }, close: function( event ) { -- 2.39.5