Skip to content
This repository has been archived by the owner on Dec 23, 2017. It is now read-only.

Fix checkbox keypress toggling adjacent dropdowns. #281

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions static/js/modules/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,25 @@ $('.js-checkbox-filters').each(function(){
$dropdownList.find('input[type=checkbox]').change(function(){
updateSelectedItems($dropdownList);
countCheckboxes(this);
}).on('keypress', function(e) {
if (e.which === 13) {
var $this = $(this);
});
});

$('.field input[type="checkbox"]').on('keypress', function(e) {
if (e.which === 13) {
var $this = $(this);
var $parent = $this.parents('ul.dropdown__list');
$this.prop('checked', function(index, value) {
return !value;
});
if ($parent.length) {
var $next = $this.parents('li').next('li').find('input[type="checkbox"]');
$(this).prop('checked', function(index, value) {
return !value;
}).change();
if ($next.length) {
$next.focus();
}
e.preventDefault();
}
});
$this.change();
e.preventDefault();
}
});

// Search-able lists
Expand Down