Skip to content

Commit

Permalink
ActionList: Don't navigate if only a is pressed
Browse files Browse the repository at this point in the history
Optimize code
  • Loading branch information
sukhwinder33445 committed Jul 29, 2024
1 parent a2d94ea commit 65b3b16
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions asset/js/widget/ActionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,9 @@ define(["../notjQuery"], function ($) {
let pressedArrowDownKey = event.key === 'ArrowDown';
let pressedArrowUpKey = event.key === 'ArrowUp';
let focusedElement = document.activeElement;
let isSelectAll = (event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'a' && this.isMultiSelectable;

if (
! event.key // input auto-completion is triggered
|| (event.key.toLowerCase() !== 'a' && ! pressedArrowDownKey && ! pressedArrowUpKey)
) {
if (! isSelectAll && ! pressedArrowDownKey && ! pressedArrowUpKey) {
return;
}

Expand All @@ -248,18 +246,12 @@ define(["../notjQuery"], function ($) {
return;
}

if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'a') {
if (! this.isMultiSelectable) {
return;
}

event.preventDefault();
event.preventDefault();
if (isSelectAll) {
this.selectAll();
return;
}

event.preventDefault();

let allItems = this.getAllItems();
let firstListItem = allItems[0];
let lastListItem = allItems[allItems.length -1];
Expand Down

0 comments on commit 65b3b16

Please sign in to comment.