Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 9707d6b

Browse files
AlexFessAleksandr Kudriashov
authored andcommitted
Fix: appendToBody with jQuery < 1.10.0; stealing focus #944
.relpaceWith in jQuery (version less then 1.10) doesn't work properly and as so, ui-select with 'appendToBody=true' doesn't display selected value. Use .after() and .remove() instead of .replaceWith() to avoid this issue. fix for #944: Don't restore focus if it was moved out of select (irregardles of target element). Otherwise it looks too confusing when clicking on links or any other control that is not an input/button/textarea.
1 parent 3642a1d commit 9707d6b

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/uiSelectDirective.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,7 @@ uis.directive('uiSelect',
190190
}
191191

192192
if (!contains && !$select.clickTriggeredSelect) {
193-
var skipFocusser;
194-
if (!$select.skipFocusser) {
195-
//Will lose focus only with certain targets
196-
var focusableControls = ['input','button','textarea','select'];
197-
var targetController = angular.element(e.target).controller('uiSelect'); //To check if target is other ui-select
198-
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-
} else {
201-
skipFocusser = true;
202-
}
203-
$select.close(skipFocusser);
193+
$select.close(true);
204194
scope.$digest();
205195
}
206196
$select.clickTriggeredSelect = false;
@@ -298,7 +288,8 @@ uis.directive('uiSelect',
298288
}
299289

300290
// Move the dropdown element back to its original location in the DOM
301-
placeholder.replaceWith(element);
291+
placeholder.after(element);
292+
placeholder.remove();
302293
placeholder = null;
303294

304295
element[0].style.position = '';

0 commit comments

Comments
 (0)