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 30, 2024
1 parent 65b3b16 commit 44dfdb3
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions asset/js/widget/ActionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,22 +269,14 @@ define(["../notjQuery"], function ($) {
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 +319,15 @@ define(["../notjQuery"], function ($) {
*/
getDirectionalNext(item, eventKey) {
if (! item) {
return null;
item = eventKey === 'ArrowUp' ? this.list.lastChild : this.list.firstChild;

if (! item) {
return null;
}

if (item.hasAttribute(this.removeBrackets(LIST_ITEM_IDENTIFIER))) {
return item;
}
}

let nextItem = null;
Expand Down

0 comments on commit 44dfdb3

Please sign in to comment.