Skip to content

Commit

Permalink
Fix drawing new layers not being put next to nested selected layers
Browse files Browse the repository at this point in the history
A regression introduced in #2110
  • Loading branch information
Keavon committed Jan 10, 2025
1 parent 07601a5 commit 51d1c4e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions editor/src/messages/portfolio/document/document_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1654,9 +1654,18 @@ impl DocumentMessageHandler {

/// Finds the artboard that bounds the point in viewport space and be the container of any newly added layers.
pub fn new_layer_bounding_artboard(&self, ipp: &InputPreprocessorMessageHandler) -> LayerNodeIdentifier {
self.click_xray(ipp)
let container_based_on_selection = self.new_layer_parent(true);

let container_based_on_clicked_artboard = self
.click_xray(ipp)
.find(|layer| self.network_interface.is_artboard(&layer.to_node(), &[]))
.unwrap_or(LayerNodeIdentifier::ROOT_PARENT)
.unwrap_or(LayerNodeIdentifier::ROOT_PARENT);

if container_based_on_selection.ancestors(self.metadata()).any(|ancestor| ancestor == container_based_on_clicked_artboard) {
container_based_on_selection
} else {
container_based_on_clicked_artboard
}
}

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

0 comments on commit 51d1c4e

Please sign in to comment.