Skip to content

Commit 872387a

Browse files
kborchersscottgonzalez
authored andcommitted
Datepicker: Added additional check to checkExternalClick to work when clicking in another datepicker and removed old fix. Fixes #7686 - infinite loop when onclose event shows a second calendar
(cherry picked from commit af76ad1)
1 parent af7d433 commit 872387a

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

ui/jquery.ui.datepicker.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -636,10 +636,10 @@ $.extend(Datepicker.prototype, {
636636
return;
637637
var inst = $.datepicker._getInst(input);
638638
if ($.datepicker._curInst && $.datepicker._curInst != inst) {
639-
if ( $.datepicker._datepickerShowing ) {
640-
$.datepicker._triggerOnClose($.datepicker._curInst);
641-
}
642639
$.datepicker._curInst.dpDiv.stop(true, true);
640+
if ( inst && $.datepicker._datepickerShowing ) {
641+
$.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
642+
}
643643
}
644644
var beforeShow = $.datepicker._get(inst, 'beforeShow');
645645
var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
@@ -788,14 +788,6 @@ $.extend(Datepicker.prototype, {
788788
return [position.left, position.top];
789789
},
790790

791-
/* Trigger custom callback of onClose. */
792-
_triggerOnClose: function(inst) {
793-
var onClose = this._get(inst, 'onClose');
794-
if (onClose)
795-
onClose.apply((inst.input ? inst.input[0] : null),
796-
[(inst.input ? inst.input.val() : ''), inst]);
797-
},
798-
799791
/* Hide the date picker from view.
800792
@param input element - the input field attached to the date picker */
801793
_hideDatepicker: function(input) {
@@ -816,8 +808,11 @@ $.extend(Datepicker.prototype, {
816808
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
817809
if (!showAnim)
818810
postProcess();
819-
$.datepicker._triggerOnClose(inst);
820811
this._datepickerShowing = false;
812+
var onClose = this._get(inst, 'onClose');
813+
if (onClose)
814+
onClose.apply((inst.input ? inst.input[0] : null),
815+
[(inst.input ? inst.input.val() : ''), inst]);
821816
this._lastInput = null;
822817
if (this._inDialog) {
823818
this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
@@ -839,12 +834,16 @@ $.extend(Datepicker.prototype, {
839834
_checkExternalClick: function(event) {
840835
if (!$.datepicker._curInst)
841836
return;
842-
var $target = $(event.target);
843-
if ($target[0].id != $.datepicker._mainDivId &&
837+
838+
var $target = $(event.target),
839+
inst = $.datepicker._getInst($target[0]);
840+
841+
if ( ( ( $target[0].id != $.datepicker._mainDivId &&
844842
$target.parents('#' + $.datepicker._mainDivId).length == 0 &&
845843
!$target.hasClass($.datepicker.markerClassName) &&
846844
!$target.hasClass($.datepicker._triggerClass) &&
847-
$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
845+
$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
846+
( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst != inst ) )
848847
$.datepicker._hideDatepicker();
849848
},
850849

0 commit comments

Comments
 (0)