Skip to content

Commit

Permalink
ActionList: getDirectionNext(): Return list's first/last elem if null…
Browse files Browse the repository at this point in the history
… is passed as item
  • Loading branch information
sukhwinder33445 committed Jul 29, 2024
1 parent 65b3b16 commit b68eea4
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions asset/js/widget/ActionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b68eea4

Please sign in to comment.