diff --git a/crates/ui/src/dropdown.rs b/crates/ui/src/dropdown.rs index 8c1160d4..edb4d89b 100644 --- a/crates/ui/src/dropdown.rs +++ b/crates/ui/src/dropdown.rs @@ -218,7 +218,7 @@ pub struct Dropdown { icon: Option, open: bool, cleanable: bool, - placeholder: SharedString, + placeholder: Option, title_prefix: Option, selected_value: Option<::Value>, empty: Option AnyElement + 'static>>, @@ -327,7 +327,7 @@ where let mut this = Self { id: id.into(), focus_handle, - placeholder: t!("Dropdown.placeholder").into(), + placeholder: None, list, size: Size::Medium, icon: None, @@ -359,7 +359,7 @@ where /// Set the placeholder for display when dropdown value is empty. pub fn placeholder(mut self, placeholder: impl Into) -> Self { - self.placeholder = placeholder.into(); + self.placeholder = Some(placeholder.into()); self } @@ -518,9 +518,11 @@ where })) .child(title.clone()) } else { - div() - .text_color(cx.theme().accent_foreground) - .child(self.placeholder.clone()) + div().text_color(cx.theme().accent_foreground).child( + self.placeholder + .clone() + .unwrap_or_else(|| t!("Dropdown.placeholder").into()), + ) }; title.when(self.disabled, |this| {