From 7ac903b076e968811d51b37bfee3dd19ca19d952 Mon Sep 17 00:00:00 2001 From: Felix Nagel Date: Thu, 3 Dec 2015 16:45:47 +0100 Subject: [PATCH] Calendar: Let datepicker handle focus after date selection --- ui/widgets/calendar.js | 10 ++++++---- ui/widgets/datepicker.js | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) 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" ); -- 2.39.5