Skip to content

Commit

Permalink
Fix liveSearch arrow navigation.
Browse files Browse the repository at this point in the history
Fix snapappointments#961. Close snapappointments#962. Close snapappointments#934. This functionality was changed in
e9c9c90. $items changes to include `li`
elements instead of `a` elements when liveSearch is enabled. This allows
us to reuse the same code.
  • Loading branch information
caseyjhol authored and avantika-gupta-jtg committed May 14, 2020
1 parent 8a778a0 commit c2d38e7
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 11 deletions.
8 changes: 4 additions & 4 deletions dist/js/bootstrap-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -1180,10 +1180,11 @@
that.$menu.parent().removeClass('open');
that.$button.focus();
}
$items = $('[role=menu] li:not(.divider):not(.dropdown-header):visible a', $parent);
// $items contains li elements when liveSearch is enabled
$items = $('[role=menu] li:not(.divider):not(.dropdown-header):visible', $parent);
if (!$this.val() && !/(38|40)/.test(e.keyCode.toString(10))) {
if ($items.filter('.active').length === 0) {
$items = that.$newElement.find('li a');
$items = that.$newElement.find('li');
if (that.options.liveSearchNormalize) {
$items = $items.filter(':a' + that._searchStyle() + '(' + normalizeToBase(keyCodeMap[e.keyCode]) + ')');
} else {
Expand Down Expand Up @@ -1239,8 +1240,7 @@
} else {
e.preventDefault();
if (!$this.hasClass('dropdown-toggle')) {
$items.removeClass('active');
$items.eq(index).addClass('active').children('a').focus();
$items.removeClass('active').eq(index).addClass('active').children('a').focus();
$this.focus();
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/js/bootstrap-select.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/bootstrap-select.min.js

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions dist/js/i18n/defaults-fa_IR.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*!
* Bootstrap-select v1.6.5 (http://silviomoreto.github.io/bootstrap-select)
*
* Copyright 2013-2015 bootstrap-select
* Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE)
*/
(function ($) {
$.fn.selectpicker.defaults = {
noneSelectedText: 'چیزی انتخاب نشده است',
noneResultsText: 'هیج مشابهی برای {0} پیدا نشد',
countSelectedText: "{0} از {1} مورد انتخاب شده",
maxOptionsText: ['بیشتر ممکن نیست {حداکثر {n} عدد}', 'بیشتر ممکن نیست {حداکثر {n} عدد}'],
selectAllText: 'انتخاب همه',
deselectAllText: 'انتخاب هیچ کدام',
multipleSeparator: ', '
};
})(jQuery);
7 changes: 7 additions & 0 deletions dist/js/i18n/defaults-fa_IR.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*!
* Bootstrap-select v1.6.5 (http://silviomoreto.github.io/bootstrap-select)
*
* Copyright 2013-2015 bootstrap-select
* Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE)
*/
!function(a){a.fn.selectpicker.defaults={noneSelectedText:"چیزی انتخاب نشده است",noneResultsText:"هیج مشابهی برای {0} پیدا نشد",countSelectedText:"{0} از {1} مورد انتخاب شده",maxOptionsText:["بیشتر ممکن نیست {حداکثر {n} عدد}","بیشتر ممکن نیست {حداکثر {n} عدد}"],selectAllText:"انتخاب همه",deselectAllText:"انتخاب هیچ کدام",multipleSeparator:", "}}(jQuery);
15 changes: 15 additions & 0 deletions dist/js/i18n/defaults-pt_PT.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*!
* Bootstrap-select v1.6.5 (http://silviomoreto.github.io/bootstrap-select)
*
* Copyright 2013-2015 bootstrap-select
* Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE)
*/
(function ($) {
$.fn.selectpicker.defaults = {
noneSelectedText: 'Nenhum seleccionado',
noneResultsText: 'Sem resultados contendo {0}',
countSelectedText: 'Selecionado {0} de {1}',
maxOptionsText: ['Limite ultrapassado (máx. {n} {var})', 'Limite de seleções ultrapassado (máx. {n} {var})', ['itens', 'item']],
multipleSeparator: ', '
};
})(jQuery);
8 changes: 7 additions & 1 deletion dist/js/i18n/defaults-pt_PT.min.js
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
!function(e){e.fn.selectpicker.defaults={noneSelectedText:"Nenhum seleccionado",noneResultsText:"Sem resultados contendo {0}",countSelectedText:"Selecionado {0} de {1}",maxOptionsText:["Limite ultrapassado (máx. {n} {var})","Limite de seleções ultrapassado (máx. {n} {var})",["itens","item"]],multipleSeparator:", "}}(jQuery);
/*!
* Bootstrap-select v1.6.5 (http://silviomoreto.github.io/bootstrap-select)
*
* Copyright 2013-2015 bootstrap-select
* Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE)
*/
!function(a){a.fn.selectpicker.defaults={noneSelectedText:"Nenhum seleccionado",noneResultsText:"Sem resultados contendo {0}",countSelectedText:"Selecionado {0} de {1}",maxOptionsText:["Limite ultrapassado (máx. {n} {var})","Limite de seleções ultrapassado (máx. {n} {var})",["itens","item"]],multipleSeparator:", "}}(jQuery);
8 changes: 4 additions & 4 deletions js/bootstrap-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -1174,10 +1174,11 @@
that.$menu.parent().removeClass('open');
that.$button.focus();
}
$items = $('[role=menu] li:not(.divider):not(.dropdown-header):visible a', $parent);
// $items contains li elements when liveSearch is enabled
$items = $('[role=menu] li:not(.divider):not(.dropdown-header):visible', $parent);
if (!$this.val() && !/(38|40)/.test(e.keyCode.toString(10))) {
if ($items.filter('.active').length === 0) {
$items = that.$newElement.find('li a');
$items = that.$newElement.find('li');
if (that.options.liveSearchNormalize) {
$items = $items.filter(':a' + that._searchStyle() + '(' + normalizeToBase(keyCodeMap[e.keyCode]) + ')');
} else {
Expand Down Expand Up @@ -1233,8 +1234,7 @@
} else {
e.preventDefault();
if (!$this.hasClass('dropdown-toggle')) {
$items.removeClass('active');
$items.eq(index).addClass('active').children('a').focus();
$items.removeClass('active').eq(index).addClass('active').children('a').focus();
$this.focus();
}
}
Expand Down

0 comments on commit c2d38e7

Please sign in to comment.