From: Felix Nagel Date: Thu, 3 Dec 2015 15:45:47 +0000 (+0100) Subject: Calendar: Let datepicker handle focus after date selection X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7ac903b076e968811d51b37bfee3dd19ca19d952;p=jquery-ui.git Calendar: Let datepicker handle focus after date selection --- diff --git a/ui/widgets/calendar.js b/ui/widgets/calendar.js index 0bbe5804f..e692995f4 100644 --- a/ui/widgets/calendar.js +++ b/ui/widgets/calendar.js @@ -98,12 +98,14 @@ return $.widget( "ui.calendar", { this._updateView(); }, "mousedown .ui-calendar-calendar button": function( event ) { - event.preventDefault(); - this._setOption( "value", new Date( $( event.currentTarget ).data( "timestamp" ) ) ); this.refresh(); - this._trigger( "select", event ); - this.activeDescendant.closest( this.grid ).focus(); + + // Allow datepicker to handle focus + if ( this._trigger( "select", event ) !== false ) { + this.activeDescendant.closest( this.grid ).focus(); + event.preventDefault(); + } }, "mouseenter .ui-calendar-header-buttons button": "_hover", "mouseleave .ui-calendar-header-buttons button": "_hover", diff --git a/ui/widgets/datepicker.js b/ui/widgets/datepicker.js index e2f77b0e7..99f34785f 100644 --- a/ui/widgets/datepicker.js +++ b/ui/widgets/datepicker.js @@ -107,8 +107,11 @@ var widget = $.widget( "ui.datepicker", { select: function( event ) { that.element.val( that.calendarInstance.value() ); that.close(); + event.preventDefault(); that._focusTrigger(); that._trigger( "select", event ); + + return false; } } ) ) .calendar( "instance" );