Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add clear filter button to outline and collab panels' search (#46210)
Danilo Lealc764f7806a1b
diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rsindex 9fddac64c06..8ed0b81f32d 100644--- a/crates/collab_ui/src/collab_panel.rs+++ b/crates/collab_ui/src/collab_panel.rs@@ -31,9 +31,8 @@ use smallvec::SmallVec;use std::{mem, sync::Arc};use theme::{ActiveTheme, ThemeSettings};use ui::{- Avatar, AvatarAvailabilityIndicator, Button, Color, ContextMenu, CopyButton, Facepile,- HighlightedLabel, Icon, IconButton, IconName, IconSize, Indicator, Label, ListHeader, ListItem,- Tab, Tooltip, prelude::*, tooltip_container,+ Avatar, AvatarAvailabilityIndicator, ContextMenu, CopyButton, Facepile, HighlightedLabel,+ IconButtonShape, Indicator, ListHeader, ListItem, Tab, Tooltip, prelude::*, tooltip_container,};use util::{ResultExt, TryFutureExt, maybe};use workspace::{@@ -2422,6 +2421,9 @@ impl CollabPanel {self.channel_store.update(cx, |channel_store, _| {channel_store.initialize();});++ let has_query = !self.filter_editor.read(cx).text(cx).is_empty();+v_flex().size_full().gap_1()@@ -2437,7 +2439,18 @@ impl CollabPanel {.size(IconSize::Small).color(Color::Muted),)- .child(self.render_filter_input(&self.filter_editor, cx)),+ .child(self.render_filter_input(&self.filter_editor, cx))+ .when(has_query, |this| {+ this.pr_2p5().child(+ IconButton::new("clear_filter", IconName::Close)+ .shape(IconButtonShape::Square)+ .tooltip(Tooltip::text("Clear Filter"))+ .on_click(cx.listener(|this, _, window, cx| {+ this.reset_filter_editor_text(window, cx);+ cx.notify();+ })),+ )+ }),).child(list(diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rsindex 5a32bd73b74..b43456264ca 100644--- a/crates/outline_panel/src/outline_panel.rs+++ b/crates/outline_panel/src/outline_panel.rs@@ -4799,6 +4799,8 @@ impl OutlinePanel {(IconName::Pin, "Pin Active Outline")};+ let has_query = self.query(cx).is_some();+h_flex().p_2().h(Tab::container_height(cx))@@ -4817,12 +4819,32 @@ impl OutlinePanel {.child(self.filter_editor.clone()),).child(- IconButton::new("pin_button", icon)- .tooltip(Tooltip::text(icon_tooltip))- .shape(IconButtonShape::Square)- .on_click(cx.listener(|outline_panel, _, window, cx| {- outline_panel.toggle_active_editor_pin(&ToggleActiveEditorPin, window, cx);- })),+ h_flex()+ .when(has_query, |this| {+ this.child(+ IconButton::new("clear_filter", IconName::Close)+ .shape(IconButtonShape::Square)+ .tooltip(Tooltip::text("Clear Filter"))+ .on_click(cx.listener(|outline_panel, _, window, cx| {+ outline_panel.filter_editor.update(cx, |editor, cx| {+ editor.set_text("", window, cx);+ });+ cx.notify();+ })),+ )+ })+ .child(+ IconButton::new("pin_button", icon)+ .tooltip(Tooltip::text(icon_tooltip))+ .shape(IconButtonShape::Square)+ .on_click(cx.listener(|outline_panel, _, window, cx| {+ outline_panel.toggle_active_editor_pin(+ &ToggleActiveEditorPin,+ window,+ cx,+ );+ })),+ ),)}