Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Integration: menu_row matches only buttons that aren't toggles (#524)

aiongg83893ba3f0b9
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs
index 1e09fbff7..3191fa296 100644
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@ -2801,10 +2801,12 @@ mod tests {
xf.to_screen(CanvasLayout::new(&st.doc, st.editing_parents).xf(SpreadRef::Doc(0)) * Point::new(x, y))
}
- /// A menu row: its label, then its shortcut if it has one.
+ /// A menu row: a button that isn't a toggle, named by its label, then its shortcut if it has
+ /// one. Toggle buttons with the same name (the Task Bar's icons) don't match.
fn menu_row<'h>(h: &'h Harness<'_, DesignApp>, label: &'h str) -> Option<egui_kittest::Node<'h>> {
h.query_by(move |n| {
n.role() == egui::accesskit::Role::Button
+ && n.toggled().is_none()
&& n.label().is_some_and(|l| l == label || l.strip_prefix(label).and_then(|r| r.strip_prefix(' ')).is_some_and(|r| !r.contains(' ')))
})
}