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.
*/
onMouseDown (hitProperties) {
debugger;
let item = hitProperties.hitResult.item;
if (!hitProperties.subselect) {
const root = getRootItem(hitProperties.hitResult.item);

View file

@ -126,22 +126,18 @@ const clearSelection = function (dispatchClearSelect) {
* @return {Array<paper.Item>} 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;
};
/**

View file

@ -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.