Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix the selected state for the panel icons in the status bar (#3450)

Marshall Bowers04bbd107c1c1
diff --git a/crates/ui2/src/components/stories/icon_button.rs b/crates/ui2/src/components/stories/icon_button.rs
index 85a9e1a0e88..e0d62af8a92 100644
--- a/crates/ui2/src/components/stories/icon_button.rs
+++ b/crates/ui2/src/components/stories/icon_button.rs
@@ -14,6 +14,12 @@ impl Render for IconButtonStory {
.child(Story::title_for::<IconButton>())
.child(Story::label("Default"))
.child(div().w_8().child(IconButton::new("icon_a", Icon::Hash)))
+ .child(Story::label("Selected"))
+ .child(
+ div()
+ .w_8()
+ .child(IconButton::new("icon_a", Icon::Hash).selected(true)),
+ )
.child(Story::label("With `on_click`"))
.child(
div()
diff --git a/crates/workspace2/src/dock.rs b/crates/workspace2/src/dock.rs
index 9dd049888fd..06fdf7f9c16 100644
--- a/crates/workspace2/src/dock.rs
+++ b/crates/workspace2/src/dock.rs
@@ -701,11 +701,6 @@ impl Render for PanelButtons {
(action, name.into())
};
- let button = IconButton::new(name, icon)
- .selected(is_active_button)
- .action(action.boxed_clone())
- .tooltip(move |cx| Tooltip::for_action(tooltip.clone(), &*action, cx));
-
Some(
menu_handle(name)
.menu(move |cx| {
@@ -731,7 +726,14 @@ impl Render for PanelButtons {
})
.anchor(menu_anchor)
.attach(menu_attach)
- .child(|is_open| button.selected(is_open)),
+ .child(move |_is_open| {
+ IconButton::new(name, icon)
+ .selected(is_active_button)
+ .action(action.boxed_clone())
+ .tooltip(move |cx| {
+ Tooltip::for_action(tooltip.clone(), &*action, cx)
+ })
+ }),
)
});