diff --git a/src/js/select2/selection/base.js b/src/js/select2/selection/base.js
index 27a1acb2..d79c960b 100644
--- a/src/js/select2/selection/base.js
+++ b/src/js/select2/selection/base.js
@@ -81,10 +81,8 @@ define([
self.$selection.removeAttr('aria-activedescendant');
self.$selection.removeAttr('aria-owns');
- window.setTimeout(function () {
- self.$selection.trigger('focus');
- }, 0);
-
+ self.$selection.trigger('focus');
+
self._detachCloseHandler(container);
});
diff --git a/tests/selection/focusing-tests.js b/tests/selection/focusing-tests.js
new file mode 100644
index 00000000..81a50492
--- /dev/null
+++ b/tests/selection/focusing-tests.js
@@ -0,0 +1,41 @@
+module('Selection containers - Managing focus');
+
+var SingleSelection = require('select2/selection/single');
+
+var $ = require('jquery');
+var Options = require('select2/options');
+
+var options = new Options({});
+
+test('close sets the focus to the selection', function (assert) {
+ var $container = $('#qunit-fixture .event-container');
+ var container = new MockContainer();
+ var selection = new SingleSelection(
+ $('#qunit-fixture .single'),
+ options
+ );
+
+ var $selection = selection.render();
+ selection.bind(container, $container);
+
+ selection.update([{
+ id: 'test',
+ text: 'test'
+ }]);
+
+ $container.append($selection);
+
+ assert.notEqual(
+ document.activeElement,
+ $selection[0],
+ 'The selection had focus originally'
+ );
+
+ container.trigger('close');
+
+ assert.equal(
+ document.activeElement,
+ $selection[0],
+ 'After close, focus must be set to selection'
+ );
+});
diff --git a/tests/unit-jq1.html b/tests/unit-jq1.html
index e0b33216..c980e2fa 100644
--- a/tests/unit-jq1.html
+++ b/tests/unit-jq1.html
@@ -1,99 +1,100 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/unit-jq2.html b/tests/unit-jq2.html
index a35b26e5..409080d4 100644
--- a/tests/unit-jq2.html
+++ b/tests/unit-jq2.html
@@ -1,99 +1,100 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/unit-jq3.html b/tests/unit-jq3.html
index 31259ea3..f3754d4a 100644
--- a/tests/unit-jq3.html
+++ b/tests/unit-jq3.html
@@ -1,99 +1,100 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+