Skip to content

Commit

Permalink
Only focus on the contained search field
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiulodro committed Aug 25, 2017
1 parent 13deb58 commit 884731d
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 14 deletions.
8 changes: 6 additions & 2 deletions dist/js/select2.full.js
Original file line number Diff line number Diff line change
Expand Up @@ -5405,7 +5405,7 @@ S2.define('select2/core',[

this.on('open', function(){
// Focus on the active element when opening dropdown.
// Needs 1 ms delay because of other 1ms setTimeouts when rendering.
// Needs 1 ms delay because of other 1 ms setTimeouts when rendering.
setTimeout(function(){
self.focusOnActiveElement();
},1);
Expand Down Expand Up @@ -5443,7 +5443,11 @@ S2.define('select2/core',[
self.focusOnActiveElement();
} else {
// Focus on the search if user starts typing.
$('.select2-search__field').focus();
var $searchField = self.$dropdown.find('.select2-search__field');
if (! $searchField.length) {
$searchField = self.$container.find('.select2-search__field');
}
$searchField.focus();
// Focus back to active selection when finished typing.
// Small delay so typed character can be read by screen reader.
setTimeout(function(){
Expand Down
2 changes: 1 addition & 1 deletion dist/js/select2.full.min.js

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions dist/js/select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -5405,7 +5405,7 @@ S2.define('select2/core',[

this.on('open', function(){
// Focus on the active element when opening dropdown.
// Needs 1 ms delay because of other 1ms setTimeouts when rendering.
// Needs 1 ms delay because of other 1 ms setTimeouts when rendering.
setTimeout(function(){
self.focusOnActiveElement();
},1);
Expand Down Expand Up @@ -5443,7 +5443,11 @@ S2.define('select2/core',[
self.focusOnActiveElement();
} else {
// Focus on the search if user starts typing.
$('.select2-search__field').focus();
var $searchField = self.$dropdown.find('.select2-search__field');
if (! $searchField.length) {
$searchField = self.$container.find('.select2-search__field');
}
$searchField.focus();
// Focus back to active selection when finished typing.
// Small delay so typed character can be read by screen reader.
setTimeout(function(){
Expand Down
2 changes: 1 addition & 1 deletion dist/js/select2.min.js

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions dist/js/selectWoo.full.js
Original file line number Diff line number Diff line change
Expand Up @@ -5405,7 +5405,7 @@ S2.define('select2/core',[

this.on('open', function(){
// Focus on the active element when opening dropdown.
// Needs 1 ms delay because of other 1ms setTimeouts when rendering.
// Needs 1 ms delay because of other 1 ms setTimeouts when rendering.
setTimeout(function(){
self.focusOnActiveElement();
},1);
Expand Down Expand Up @@ -5443,7 +5443,11 @@ S2.define('select2/core',[
self.focusOnActiveElement();
} else {
// Focus on the search if user starts typing.
$('.select2-search__field').focus();
var $searchField = self.$dropdown.find('.select2-search__field');
if (! $searchField.length) {
$searchField = self.$container.find('.select2-search__field');
}
$searchField.focus();
// Focus back to active selection when finished typing.
// Small delay so typed character can be read by screen reader.
setTimeout(function(){
Expand Down
2 changes: 1 addition & 1 deletion dist/js/selectWoo.full.min.js

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions dist/js/selectWoo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5405,7 +5405,7 @@ S2.define('select2/core',[

this.on('open', function(){
// Focus on the active element when opening dropdown.
// Needs 1 ms delay because of other 1ms setTimeouts when rendering.
// Needs 1 ms delay because of other 1 ms setTimeouts when rendering.
setTimeout(function(){
self.focusOnActiveElement();
},1);
Expand Down Expand Up @@ -5443,7 +5443,11 @@ S2.define('select2/core',[
self.focusOnActiveElement();
} else {
// Focus on the search if user starts typing.
$('.select2-search__field').focus();
var $searchField = self.$dropdown.find('.select2-search__field');
if (! $searchField.length) {
$searchField = self.$container.find('.select2-search__field');
}
$searchField.focus();
// Focus back to active selection when finished typing.
// Small delay so typed character can be read by screen reader.
setTimeout(function(){
Expand Down
2 changes: 1 addition & 1 deletion dist/js/selectWoo.min.js

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions src/js/select2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ define([

this.on('open', function(){
// Focus on the active element when opening dropdown.
// Needs 1 ms delay because of other 1ms setTimeouts when rendering.
// Needs 1 ms delay because of other 1 ms setTimeouts when rendering.
setTimeout(function(){
self.focusOnActiveElement();
},1);
Expand Down Expand Up @@ -356,7 +356,11 @@ define([
self.focusOnActiveElement();
} else {
// Focus on the search if user starts typing.
$('.select2-search__field').focus();
var $searchField = self.$dropdown.find('.select2-search__field');
if (! $searchField.length) {
$searchField = self.$container.find('.select2-search__field');
}
$searchField.focus();
// Focus back to active selection when finished typing.
// Small delay so typed character can be read by screen reader.
setTimeout(function(){
Expand Down

0 comments on commit 884731d

Please sign in to comment.