diff --git a/asset/js/widget/ActionList.js b/asset/js/widget/ActionList.js index 17038465..4772b4aa 100644 --- a/asset/js/widget/ActionList.js +++ b/asset/js/widget/ActionList.js @@ -262,29 +262,17 @@ define(["../notjQuery"], function ($) { `[data-icinga-detail-filter="${ this.lastActivatedItemUrl }"]` ); - if (! lastActivatedItem && activeItems.length) { - lastActivatedItem = activeItems[activeItems.length - 1]; - } - let directionalNextItem = this.getDirectionalNext(lastActivatedItem, event.key); if (activeItems.length === 0) { - toActiveItem = pressedArrowDownKey ? firstListItem : lastListItem; + toActiveItem = directionalNextItem; // reset all on manual page refresh this.clearSelection(activeItems); } else if (this.isMultiSelectable && event.shiftKey) { if (activeItems.length === 1) { toActiveItem = directionalNextItem; - } else if (wasAllSelected && ( - (lastActivatedItem !== firstListItem && pressedArrowDownKey) - || (lastActivatedItem !== lastListItem && pressedArrowUpKey) - )) { - if (pressedArrowDownKey) { - toActiveItem = lastActivatedItem === lastListItem ? null : lastListItem; - } else { - toActiveItem = lastActivatedItem === firstListItem ? null : lastListItem; - } - + } else if (wasAllSelected && (lastActivatedItem !== firstListItem && pressedArrowDownKey)) { + toActiveItem = lastActivatedItem === lastListItem ? null : lastListItem; } else if (directionalNextItem && directionalNextItem.classList.contains('active')) { // deactivate last activated by down to up select this.clearSelection([lastActivatedItem]); @@ -327,7 +315,11 @@ define(["../notjQuery"], function ($) { */ getDirectionalNext(item, eventKey) { if (! item) { - return null; + item = eventKey === 'ArrowUp' ? this.list.lastChild : this.list.firstChild; + + if (item && item.hasAttribute(this.removeBrackets(LIST_ITEM_IDENTIFIER))) { + return item; + } } let nextItem = null;