From 46324fecc692d21aa3648c168b8df89c7031cbb6 Mon Sep 17 00:00:00 2001 From: Vectornaut Date: Sat, 8 Feb 2025 06:08:36 +0000 Subject: [PATCH] Use workaround to keep representation coordinates in order (#46) This fixes #41 by rendering representation vectors with a static list view rather than an `Indexed` view. The Sycamore maintainer has confirmed that `Indexed` is always supposed to display list items in order, so I think #41 is likely caused by a bug in `Indexed`. We should consider reverting this pull request when the bug is fixed. Co-authored-by: Aaron Fenyes Reviewed-on: https://code.studioinfinity.org/glen/dyna3/pulls/46 Co-authored-by: Vectornaut Co-committed-by: Vectornaut --- app-proto/src/outline.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/app-proto/src/outline.rs b/app-proto/src/outline.rs index 148f870..a6e968d 100644 --- a/app-proto/src/outline.rs +++ b/app-proto/src/outline.rs @@ -64,11 +64,16 @@ fn ElementOutlineItem(key: ElementKey, element: assembly::Element) -> View { move |sel| if sel.contains(&key) { "selected" } else { "" } ); let label = element.label.clone(); - let rep_components = element.representation.map( - |rep| rep.iter().map( - |u| format!("{:.3}", u).replace("-", "\u{2212}") - ).collect() - ); + let rep_components = move || { + element.representation.with( + |rep| rep.iter().map( + |u| { + let u_str = format!("{:.3}", u).replace("-", "\u{2212}"); + view! { div { (u_str) } } + } + ).collect::>() + ) + }; let constrained = element.constraints.map(|csts| csts.len() > 0); let constraint_list = element.constraints.map( |csts| csts.clone().into_iter().collect() @@ -129,14 +134,7 @@ fn ElementOutlineItem(key: ElementKey, element: assembly::Element) -> View { } ) { div(class="element-label") { (label) } - div(class="element-representation") { - Indexed( - list=rep_components, - view=|coord_str| view! { - div { (coord_str) } - } - ) - } + div(class="element-representation") { (rep_components) } div(class="status") } }