From d6fc2383593f62d17aafdc0204d64ee8418fce59 Mon Sep 17 00:00:00 2001 From: DD Date: Fri, 20 Oct 2017 11:05:55 -0400 Subject: [PATCH] Fix an issue where undoing when there is a bounding box would cause the whole layer to be selected --- src/helper/selection-tools/move-tool.js | 1 + src/helper/selection.js | 18 +++++++----------- src/helper/tools/rect-tool.js | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/helper/selection-tools/move-tool.js b/src/helper/selection-tools/move-tool.js index 778c47c9..6331d0ec 100644 --- a/src/helper/selection-tools/move-tool.js +++ b/src/helper/selection-tools/move-tool.js @@ -33,6 +33,7 @@ class MoveTool { * select the whole group. */ onMouseDown (hitProperties) { + debugger; let item = hitProperties.hitResult.item; if (!hitProperties.subselect) { const root = getRootItem(hitProperties.hitResult.item); diff --git a/src/helper/selection.js b/src/helper/selection.js index dde6802f..5fbe0f96 100644 --- a/src/helper/selection.js +++ b/src/helper/selection.js @@ -126,22 +126,18 @@ const clearSelection = function (dispatchClearSelect) { * @return {Array} in increasing Z order. */ const getSelectedRootItems = function () { - const allItems = paper.project.selectedItems; - const itemsAndGroups = []; + const allItems = getAllSelectableRootItems(); + const items = []; - for (let i = 0; i < allItems.length; i++) { - const item = allItems[i]; - if ((isGroup(item) && !isGroup(item.parent)) || - !isGroup(item.parent)) { - if (item.data && !item.data.isSelectionBound) { - itemsAndGroups.push(item); - } + for (const item of allItems) { + if (item.selected) { + items.push(item); } } // sort items by index (0 at bottom) - itemsAndGroups.sort((a, b) => parseFloat(a.index) - parseFloat(b.index)); - return itemsAndGroups; + items.sort((a, b) => parseFloat(a.index) - parseFloat(b.index)); + return items; }; /** diff --git a/src/helper/tools/rect-tool.js b/src/helper/tools/rect-tool.js index db0368c9..20a18b40 100644 --- a/src/helper/tools/rect-tool.js +++ b/src/helper/tools/rect-tool.js @@ -21,7 +21,7 @@ class RectTool extends paper.Tool { this.clearSelectedItems = clearSelectedItems; this.onUpdateSvg = onUpdateSvg; this.prevHoveredItemId = null; - this.boundingBoxTool = new BoundingBoxTool(Modes.SELECT, setSelectedItems, clearSelectedItems, onUpdateSvg); + this.boundingBoxTool = new BoundingBoxTool(Modes.RECT, setSelectedItems, clearSelectedItems, onUpdateSvg); // We have to set these functions instead of just declaring them because // paper.js tools hook up the listeners in the setter functions.