Skip to content

Commit e62977e

Browse files
authored
Fix Alt-clicking the node already feeding the output blanking all the artwork (#4708)
1 parent 13b481d commit e62977e

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

‎editor/src/messages/portfolio/document/utility_types/network_interface/characterization_tests.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,15 +1353,15 @@ async fn toggle_preview_transitions_with_a_connected_export() {
13531353
assert_eq!(export_node(network_interface), Some(artboard));
13541354
assert_eq!(network_interface.previewing(&[]), Previewing::No);
13551355

1356-
// Toggling the restore node while previewing promotes it to the export with nothing left to restore
1356+
// Toggling the restore node while previewing ends the preview by restoring it
13571357
network_interface.toggle_preview(node, &[]);
13581358
network_interface.toggle_preview(artboard, &[]);
13591359
assert_eq!(export_node(network_interface), Some(artboard));
1360-
assert_eq!(network_interface.previewing(&[]), Previewing::Yes { root_node_to_restore: None });
1360+
assert_eq!(network_interface.previewing(&[]), Previewing::No);
13611361

1362-
// Toggling it once more ends the preview by disconnecting the export entirely
1362+
// Toggling the node already feeding the export changes nothing
13631363
network_interface.toggle_preview(artboard, &[]);
1364-
assert_eq!(export_node(network_interface), None);
1364+
assert_eq!(export_node(network_interface), Some(artboard));
13651365
assert_eq!(network_interface.previewing(&[]), Previewing::No);
13661366

13671367
assert_invariants(&editor, "after cycling through the preview states");

‎editor/src/messages/portfolio/document/utility_types/network_interface/mutations.rs‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,8 +1291,13 @@ impl NodeNetworkInterface {
12911291
new_export = root_node_to_restore.map(|root_node| root_node.to_connector());
12921292
new_previewing_state = Previewing::No;
12931293
}
1294-
// The export is clicked and there is no preview
1294+
// The export is clicked and there is no preview, so it already shows the primary output a preview would
1295+
else if previous_output_index == 0 {
1296+
return;
1297+
}
1298+
// The export is clicked and there is no preview, but it comes from another output, so preview the primary one and restore that afterward
12951299
else {
1300+
new_export = Some(OutputConnector::primary_output(toggle_id));
12961301
new_previewing_state = Previewing::Yes {
12971302
root_node_to_restore: Some(RootNode {
12981303
node_id: previous_export_id,
@@ -1309,10 +1314,10 @@ impl NodeNetworkInterface {
13091314
if let Previewing::Yes { root_node_to_restore } = self.previewing(network_path) {
13101315
// There is also a solid line being drawn
13111316
if let Some(root_node_to_restore) = root_node_to_restore {
1312-
// If the node with the solid line is clicked, then start previewing that node without restore
1317+
// If the node with the solid line is clicked, then end the preview by restoring it
13131318
if root_node_to_restore.node_id == toggle_id {
1314-
new_export = Some(OutputConnector::primary_output(toggle_id));
1315-
new_previewing_state = Previewing::Yes { root_node_to_restore: None };
1319+
new_export = Some(root_node_to_restore.to_connector());
1320+
new_previewing_state = Previewing::No;
13161321
} else {
13171322
// Root node to restore does not change
13181323
new_previewing_state = Previewing::Yes {

0 commit comments

Comments
 (0)