@@ -180,23 +180,24 @@ uis.directive('uiSelect',
180
180
if ( ! $select . open ) return ; //Skip it if dropdown is close
181
181
182
182
var contains = false ;
183
+ var target = e . target || e . srcElement ;
183
184
184
185
if ( window . jQuery ) {
185
186
// Firefox 3.6 does not support element.contains()
186
187
// 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 ) ;
188
189
} else {
189
- contains = element [ 0 ] . contains ( e . target ) ;
190
+ contains = element [ 0 ] . contains ( target ) ;
190
191
}
191
192
192
193
if ( ! contains && ! $select . clickTriggeredSelect ) {
193
194
var skipFocusser ;
194
195
if ( ! $select . skipFocusser ) {
195
196
//Will lose focus only with certain targets
196
197
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
198
199
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
200
201
} else {
201
202
skipFocusser = true ;
202
203
}
@@ -206,11 +207,12 @@ uis.directive('uiSelect',
206
207
$select . clickTriggeredSelect = false ;
207
208
}
208
209
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 ) ;
211
213
212
214
scope . $on ( '$destroy' , function ( ) {
213
- $ document. off ( 'click' , onDocumentClick ) ;
215
+ document . removeEventListener ( 'click' , onDocumentClick , true ) ;
214
216
} ) ;
215
217
216
218
// Move transcluded elements to their correct position in main template
0 commit comments