Skip to content

Commit 967e581

Browse files
committed
Calendar: Make sure keydown original event is available
1 parent d1152a3 commit 967e581

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

ui/widgets/calendar.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,7 @@ return $.widget( "ui.calendar", {
108108
this.date.adjust( "M", this.options.numberOfMonths );
109109
this._updateView();
110110
},
111-
"mousedown .ui-calendar-calendar button": function( event ) {
112-
this._setOption( "value", new Date( $( event.currentTarget ).data( "timestamp" ) ) );
113-
this._updateDayElement( "ui-state-active" );
114-
115-
// Allow datepicker to handle focus
116-
if ( this._trigger( "select", event ) !== false ) {
117-
this.activeDescendant.closest( this.grid ).focus();
118-
event.preventDefault();
119-
}
120-
},
111+
"mousedown .ui-calendar-calendar button": "_select",
121112
"mouseenter .ui-calendar-header-buttons button": "_hover",
122113
"mouseleave .ui-calendar-header-buttons button": "_hover",
123114
"mouseenter .ui-calendar-calendar button": "_hover",
@@ -133,12 +124,25 @@ return $.widget( "ui.calendar", {
133124
this._addClass( $( event.currentTarget ), null, "ui-state-hover" );
134125
},
135126

127+
_select: function( event ) {
128+
this._setOption( "value", new Date( $( event.currentTarget ).data( "timestamp" ) ) );
129+
this._updateDayElement( "ui-state-active" );
130+
131+
// Allow datepicker to handle focus
132+
if ( this._trigger( "select", event ) !== false ) {
133+
this.activeDescendant.closest( this.grid ).focus();
134+
event.preventDefault();
135+
}
136+
},
137+
136138
_handleKeydown: function( event ) {
137139
var pageAltKey = ( event.altKey || event.ctrlKey && event.shiftKey );
138140

139141
switch ( event.keyCode ) {
140142
case $.ui.keyCode.ENTER:
141-
this.activeDescendant.mousedown();
143+
this._select(
144+
$.Event( event, { currentTarget: this.activeDescendant[ 0 ] } )
145+
);
142146
return;
143147
case $.ui.keyCode.PAGE_UP:
144148
this.date.adjust( pageAltKey ? "Y" : "M", -1 );

0 commit comments

Comments
 (0)