]> source.dussan.org Git - jquery-ui.git/commitdiff
Calendar: Let datepicker handle focus after date selection
authorFelix Nagel <info@felixnagel.com>
Thu, 3 Dec 2015 15:45:47 +0000 (16:45 +0100)
committerFelix Nagel <info@felixnagel.com>
Wed, 20 Jan 2016 11:16:55 +0000 (12:16 +0100)
ui/widgets/calendar.js
ui/widgets/datepicker.js

index 0bbe5804f24e8750c3f7730195a26f6aa5dfdfde..e692995f4f60fa2a8351ad78041d2d55527e945d 100644 (file)
@@ -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",
index e2f77b0e7b9c3c67deae6c6a9ed19b1bdcc18983..99f34785f008b4bce045ba63911d3ea040673e58 100644 (file)
@@ -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" );