Skip to content

Commit 18f227e

Browse files
authored
Merge pull request #4 from bdb-opensource/AB-7284/capture-document-click
[AB-7284] Client/Add/Edit User: bdb-ignore-event on select-wrap prevents closing the select dropdown
2 parents fbea323 + 2c6fda5 commit 18f227e

File tree

7 files changed

+58
-54
lines changed

7 files changed

+58
-54
lines changed

dist/select.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* ui-select
33
* http://github.com/angular-ui/ui-select
4-
* Version: 0.19.8 - 2018-10-15T10:14:30.715Z
4+
* Version: 0.19.8 - 2018-11-13T17:44:25.067Z
55
* License: MIT
66
*/
77

dist/select.js

Lines changed: 42 additions & 40 deletions
Large diffs are not rendered by default.

dist/select.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/select.min.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/select.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/select.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uiSelectDirective.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,23 +180,24 @@ uis.directive('uiSelect',
180180
if (!$select.open) return; //Skip it if dropdown is close
181181

182182
var contains = false;
183+
var target = e.target || e.srcElement;
183184

184185
if (window.jQuery) {
185186
// Firefox 3.6 does not support element.contains()
186187
// See Node.contains https://developer.mozilla.org/en-US/docs/Web/API/Node.contains
187-
contains = window.jQuery.contains(element[0], e.target);
188+
contains = window.jQuery.contains(element[0], target);
188189
} else {
189-
contains = element[0].contains(e.target);
190+
contains = element[0].contains(target);
190191
}
191192

192193
if (!contains && !$select.clickTriggeredSelect) {
193194
var skipFocusser;
194195
if (!$select.skipFocusser) {
195196
//Will lose focus only with certain targets
196197
var focusableControls = ['input','button','textarea','select'];
197-
var targetController = angular.element(e.target).controller('uiSelect'); //To check if target is other ui-select
198+
var targetController = angular.element(target).controller('uiSelect'); //To check if target is other ui-select
198199
skipFocusser = targetController && targetController !== $select; //To check if target is other ui-select
199-
if (!skipFocusser) skipFocusser = ~focusableControls.indexOf(e.target.tagName.toLowerCase()); //Check if target is input, button or textarea
200+
if (!skipFocusser) skipFocusser = ~focusableControls.indexOf(target.tagName.toLowerCase()); //Check if target is input, button or textarea
200201
} else {
201202
skipFocusser = true;
202203
}
@@ -206,11 +207,12 @@ uis.directive('uiSelect',
206207
$select.clickTriggeredSelect = false;
207208
}
208209

209-
// See Click everywhere but here event http://stackoverflow.com/questions/12931369
210-
$document.on('click', onDocumentClick);
210+
// Close the event handler when any event is clicked. This should capture in case any parent
211+
// element cancels propagation of the click event. RIP IE8. http://stackoverflow.com/questions/12931369
212+
document.addEventListener('click', onDocumentClick, true);
211213

212214
scope.$on('$destroy', function() {
213-
$document.off('click', onDocumentClick);
215+
document.removeEventListener('click', onDocumentClick, true);
214216
});
215217

216218
// Move transcluded elements to their correct position in main template

0 commit comments

Comments
 (0)