Skip to content

Commit

Permalink
filter only the dropdown-item elements (not header/footer/custom ones)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yair Even Or authored and Yair Even Or committed Jul 9, 2022
1 parent 008f10e commit c97aecd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/parts/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,15 @@ export default {
case 'Down' : // >IE11
case 'Up' : { // >IE11
e.preventDefault()
var dropdownItems;
var dropdownItems, isDDItem;

if( selectedElm )
selectedElm = selectedElm[(e.key == 'ArrowUp' || e.key == 'Up' ? "previous" : "next") + "ElementSibling"];

// if no element was found, loop
if( !selectedElm ){
dropdownItems = this.DOM.dropdown.content.children
// if no element was found OR current item is not a "real" item, loop
if( !selectedElm || !selectedElm.matches(this.settings.classNames.dropdownItemSelector) ){
// filter only the dropdown-item elements (not header/footer/custom ones)
dropdownItems = this.DOM.dropdown.content.querySelectorAll(this.settings.classNames.dropdownItemSelector)
selectedElm = dropdownItems[e.key == 'ArrowUp' || e.key == 'Up' ? dropdownItems.length - 1 : 0];
}

Expand Down

0 comments on commit c97aecd

Please sign in to comment.