Insert duplicated layers directly above their selected source layers (#1726)

Make insert index of duplicated layer on top of layer that's being duplicated
This commit is contained in:
Haikal 2024-04-18 12:01:21 +07:00 committed by GitHub
parent e55578a016
commit 1ccd8ae4ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -297,7 +297,8 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
.collect();
let id = NodeId(generate_uuid());
let insert_index = -1;
let selected_layer_index = parent.children(self.metadata()).collect::<Vec<_>>().iter().position(|&sibling| sibling == layer).unwrap_or(0);
let insert_index = if (selected_layer_index as i64 - 1) < 0 { -1 } else { selected_layer_index as isize };
responses.add(GraphOperationMessage::NewCustomLayer {
id,
nodes,