Skip to content

Commit

Permalink
fix(datepicker): add check for contains
Browse files Browse the repository at this point in the history
Closes angular-ui#4423
Fixes angular-ui#4411

# Conflicts:
#	src/datepicker/datepicker.js

Cherry picked commit from original repository: angular-ui@868c0e2?diff=split
  • Loading branch information
yjukaku authored and menelaosbgr committed Dec 23, 2015
1 parent eec1608 commit 9d3d59a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,8 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
return; // do nothing
}
$scope.select(self.activeDate);
focusElement();
} else if (evt.ctrlKey && (key === 'up' || key === 'down')) {
$scope.toggleMode(key === 'up' ? 1 : -1);
focusElement();
} else {
self.handleKeyDown(key, evt);
self.refreshView();
Expand Down Expand Up @@ -595,7 +593,7 @@ function($compile, $parse, $document, $rootScope, $position, dateFilter, datePar
delete options.initDate;
}
angular.forEach(options, function(value, option) {
datepickerEl.attr( cameltoDash(option), value );
datepickerEl.attr(cameltoDash(option), value);
});
}

Expand Down Expand Up @@ -715,7 +713,12 @@ function($compile, $parse, $document, $rootScope, $position, dateFilter, datePar
});

var documentClickBind = function(event) {
if (scope.isOpen && !(element[0].contains(event.target) || popupEl[0].contains(event.target))) {
var popup = $popup[0];
var dpContainsTarget = element[0].contains(event.target);
// The popup node may not be an element node
// In some browsers (IE) only element nodes have the 'contains' function
var popupContainsTarget = popup.contains !== undefined && popup.contains(event.target);
if (scope.isOpen && !(dpContainsTarget || popupContainsTarget)) {
scope.$apply(function() {
scope.isOpen = false;
});
Expand Down

0 comments on commit 9d3d59a

Please sign in to comment.