From 49a53e765412c90ea0132050e3de063936a6aceb Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner <53836821+bennetbo@users.noreply.github.com> Date: Wed, 21 Feb 2024 22:08:20 +0100 Subject: [PATCH] titlebar: show placeholder when no project is selected (#8021) When no project is selected, the recent project dropdown is displaying an empty string, making the button basically impossible to click. This PR adds a placeholder value for that case. Here is what it looks like now: ![image](https://github.com/zed-industries/zed/assets/53836821/c831a1eb-722e-4189-8f8b-8b3039daf8f8) Release Notes: - Added placeholder to titlebar when no project is selected --- crates/collab_ui/src/collab_titlebar_item.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index f6e1299437b3f5beaf544ffa0b5a7abb584f1fcf..33d769b1d9942c795fa07ad343eebcd70e690a18 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -421,14 +421,20 @@ impl CollabTitlebarItem { worktree.root_name() }); - names.next().unwrap_or("") + names.next() + }; + let is_project_selected = name.is_some(); + let name = if let Some(name) = name { + util::truncate_and_trailoff(name, MAX_PROJECT_NAME_LENGTH) + } else { + "Open recent project".to_string() }; - let name = util::truncate_and_trailoff(name, MAX_PROJECT_NAME_LENGTH); let workspace = self.workspace.clone(); popover_menu("project_name_trigger") .trigger( Button::new("project_name_trigger", name) + .when(!is_project_selected, |b| b.color(Color::Muted)) .style(ButtonStyle::Subtle) .label_size(LabelSize::Small) .tooltip(move |cx| Tooltip::text("Recent Projects", cx)),