From 14384fc40fab96fe1dcb6afcdbb5eec4ad4b2772 Mon Sep 17 00:00:00 2001 From: nmccready Date: Fri, 7 Oct 2016 10:24:20 -0400 Subject: [PATCH] fix(dropdown): exit keybind is not open - Exit keybindFilter if the $scope is not present Closes #6278 Fixes #6208 --- src/dropdown/dropdown.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dropdown/dropdown.js b/src/dropdown/dropdown.js index 3383c904d6..ce4816cd5e 100644 --- a/src/dropdown/dropdown.js +++ b/src/dropdown/dropdown.js @@ -22,9 +22,9 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position']) this.close = function(dropdownScope, element) { if (openScope === dropdownScope) { - openScope = null; $document.off('click', closeDropdown); $document.off('keydown', this.keybindFilter); + openScope = null; } }; @@ -57,6 +57,11 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position']) }; this.keybindFilter = function(evt) { + if (!openScope) { + // see this.close as ESC could have been pressed which kills the scope so we can not proceed + return; + } + var dropdownElement = openScope.getDropdownElement(); var toggleElement = openScope.getToggleElement(); var dropdownElementTargeted = dropdownElement && dropdownElement[0].contains(evt.target);