Skip to content

Commit 51d1c4e

Browse files
committed
Fix drawing new layers not being put next to nested selected layers
A regression introduced in #2110
1 parent 07601a5 commit 51d1c4e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

editor/src/messages/portfolio/document/document_message_handler.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,9 +1654,18 @@ impl DocumentMessageHandler {
16541654

16551655
/// Finds the artboard that bounds the point in viewport space and be the container of any newly added layers.
16561656
pub fn new_layer_bounding_artboard(&self, ipp: &InputPreprocessorMessageHandler) -> LayerNodeIdentifier {
1657-
self.click_xray(ipp)
1657+
let container_based_on_selection = self.new_layer_parent(true);
1658+
1659+
let container_based_on_clicked_artboard = self
1660+
.click_xray(ipp)
16581661
.find(|layer| self.network_interface.is_artboard(&layer.to_node(), &[]))
1659-
.unwrap_or(LayerNodeIdentifier::ROOT_PARENT)
1662+
.unwrap_or(LayerNodeIdentifier::ROOT_PARENT);
1663+
1664+
if container_based_on_selection.ancestors(self.metadata()).any(|ancestor| ancestor == container_based_on_clicked_artboard) {
1665+
container_based_on_selection
1666+
} else {
1667+
container_based_on_clicked_artboard
1668+
}
16601669
}
16611670

16621671
/// Finds the parent folder which, based on the current selections, should be the container of any newly added layers.

0 commit comments

Comments
 (0)