Fix an issue where undoing when there is a bounding box would cause the whole layer to be selected

This commit is contained in:
DD 2017-10-20 11:05:55 -04:00
parent dbe24ed50c
commit d6fc238359
3 changed files with 9 additions and 12 deletions

View file

@ -33,6 +33,7 @@ class MoveTool {
* select the whole group. * select the whole group.
*/ */
onMouseDown (hitProperties) { onMouseDown (hitProperties) {
debugger;
let item = hitProperties.hitResult.item; let item = hitProperties.hitResult.item;
if (!hitProperties.subselect) { if (!hitProperties.subselect) {
const root = getRootItem(hitProperties.hitResult.item); const root = getRootItem(hitProperties.hitResult.item);

View file

@ -126,22 +126,18 @@ const clearSelection = function (dispatchClearSelect) {
* @return {Array<paper.Item>} in increasing Z order. * @return {Array<paper.Item>} in increasing Z order.
*/ */
const getSelectedRootItems = function () { const getSelectedRootItems = function () {
const allItems = paper.project.selectedItems; const allItems = getAllSelectableRootItems();
const itemsAndGroups = []; const items = [];
for (let i = 0; i < allItems.length; i++) { for (const item of allItems) {
const item = allItems[i]; if (item.selected) {
if ((isGroup(item) && !isGroup(item.parent)) || items.push(item);
!isGroup(item.parent)) {
if (item.data && !item.data.isSelectionBound) {
itemsAndGroups.push(item);
}
} }
} }
// sort items by index (0 at bottom) // sort items by index (0 at bottom)
itemsAndGroups.sort((a, b) => parseFloat(a.index) - parseFloat(b.index)); items.sort((a, b) => parseFloat(a.index) - parseFloat(b.index));
return itemsAndGroups; return items;
}; };
/** /**

View file

@ -21,7 +21,7 @@ class RectTool extends paper.Tool {
this.clearSelectedItems = clearSelectedItems; this.clearSelectedItems = clearSelectedItems;
this.onUpdateSvg = onUpdateSvg; this.onUpdateSvg = onUpdateSvg;
this.prevHoveredItemId = null; 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 // We have to set these functions instead of just declaring them because
// paper.js tools hook up the listeners in the setter functions. // paper.js tools hook up the listeners in the setter functions.