From 4204adf60f604656080a1691a5507d709f26bd72 Mon Sep 17 00:00:00 2001 From: David Back Date: Thu, 27 Sep 2018 16:59:23 -0700 Subject: [PATCH] fix deselecting entity when re-clicking row, fix ctrl/shift selections --- scripts/system/html/js/entityList.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index b2a73dfd70..3825cf9fe3 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -191,7 +191,8 @@ function loaded() { if (clickEvent.ctrlKey) { let selectedIndex = selectedEntities.indexOf(entityID); if (selectedIndex >= 0) { - selection = selectedEntities; + selection = []; + selection = selection.concat(selectedEntities); selection.splice(selectedIndex, 1) } else { selection = selection.concat(selectedEntities); @@ -210,15 +211,19 @@ function loaded() { if (previousItemFound !== -1 && clickedItemFound !== -1) { let betweenItems = []; let toItem = Math.max(previousItemFound, clickedItemFound); - // skip first and last item in this loop, we add them to selection after the loop - for (let i = (Math.min(previousItemFound, clickedItemFound) + 1); i < toItem; i++) { + for (let i = Math.min(previousItemFound, clickedItemFound); i <= toItem; i++) { betweenItems.push(visibleEntities[i].id); } if (previousItemFound > clickedItemFound) { // always make sure that we add the items in the right order betweenItems.reverse(); } - selection = selection.concat(betweenItems, selectedEntities); + selection = betweenItems; + } + } else if (!clickEvent.ctrlKey && !clickEvent.shiftKey && selectedEntities.length === 1) { + // if reselecting the same entity then deselect it + if (selectedEntities[0] === entityID) { + selection = []; } }