[Layout] Deselect object after removal
If the selected object is not in the composition, deselect it. Add tests. Fixes #1731
This commit is contained in:
@@ -26,8 +26,12 @@
|
|||||||
* @namespace platform/features/layout
|
* @namespace platform/features/layout
|
||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
['./LayoutDrag'],
|
[
|
||||||
function (LayoutDrag) {
|
'./LayoutDrag'
|
||||||
|
],
|
||||||
|
function (
|
||||||
|
LayoutDrag
|
||||||
|
) {
|
||||||
|
|
||||||
var DEFAULT_DIMENSIONS = [12, 8],
|
var DEFAULT_DIMENSIONS = [12, 8],
|
||||||
DEFAULT_GRID_SIZE = [32, 32],
|
DEFAULT_GRID_SIZE = [32, 32],
|
||||||
@@ -124,6 +128,10 @@ define(
|
|||||||
self.select(null, self.droppedIdToSelectAfterRefresh);
|
self.select(null, self.droppedIdToSelectAfterRefresh);
|
||||||
delete self.droppedIdToSelectAfterRefresh;
|
delete self.droppedIdToSelectAfterRefresh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (composition.indexOf(self.selectedId) === -1) {
|
||||||
|
self.clearSelection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -424,6 +424,17 @@ define(
|
|||||||
expect(selectedObj.showFrame).toEqual(jasmine.any(Function));
|
expect(selectedObj.showFrame).toEqual(jasmine.any(Function));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("deselects the object that is no longer in the composition", function () {
|
||||||
|
mockScope.$watchCollection.mostRecentCall.args[1]();
|
||||||
|
var childObj = mockCompositionObjects[0];
|
||||||
|
controller.select(mockEvent, childObj.getId());
|
||||||
|
|
||||||
|
var composition = ["b", "c"];
|
||||||
|
mockScope.$watchCollection.mostRecentCall.args[1](composition);
|
||||||
|
|
||||||
|
expect(controller.selected(childObj)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user