dropdown: Fix Dropdown placeholder to support change locale. (#203)
This commit is contained in:
parent
af09525c1e
commit
f611b599aa
1 changed files with 8 additions and 6 deletions
|
|
@ -218,7 +218,7 @@ pub struct Dropdown<D: DropdownDelegate + 'static> {
|
||||||
icon: Option<IconName>,
|
icon: Option<IconName>,
|
||||||
open: bool,
|
open: bool,
|
||||||
cleanable: bool,
|
cleanable: bool,
|
||||||
placeholder: SharedString,
|
placeholder: Option<SharedString>,
|
||||||
title_prefix: Option<SharedString>,
|
title_prefix: Option<SharedString>,
|
||||||
selected_value: Option<<D::Item as DropdownItem>::Value>,
|
selected_value: Option<<D::Item as DropdownItem>::Value>,
|
||||||
empty: Option<Box<dyn Fn(&WindowContext) -> AnyElement + 'static>>,
|
empty: Option<Box<dyn Fn(&WindowContext) -> AnyElement + 'static>>,
|
||||||
|
|
@ -327,7 +327,7 @@ where
|
||||||
let mut this = Self {
|
let mut this = Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
focus_handle,
|
focus_handle,
|
||||||
placeholder: t!("Dropdown.placeholder").into(),
|
placeholder: None,
|
||||||
list,
|
list,
|
||||||
size: Size::Medium,
|
size: Size::Medium,
|
||||||
icon: None,
|
icon: None,
|
||||||
|
|
@ -359,7 +359,7 @@ where
|
||||||
|
|
||||||
/// Set the placeholder for display when dropdown value is empty.
|
/// Set the placeholder for display when dropdown value is empty.
|
||||||
pub fn placeholder(mut self, placeholder: impl Into<SharedString>) -> Self {
|
pub fn placeholder(mut self, placeholder: impl Into<SharedString>) -> Self {
|
||||||
self.placeholder = placeholder.into();
|
self.placeholder = Some(placeholder.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -518,9 +518,11 @@ where
|
||||||
}))
|
}))
|
||||||
.child(title.clone())
|
.child(title.clone())
|
||||||
} else {
|
} else {
|
||||||
div()
|
div().text_color(cx.theme().accent_foreground).child(
|
||||||
.text_color(cx.theme().accent_foreground)
|
self.placeholder
|
||||||
.child(self.placeholder.clone())
|
.clone()
|
||||||
|
.unwrap_or_else(|| t!("Dropdown.placeholder").into()),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
title.when(self.disabled, |this| {
|
title.when(self.disabled, |this| {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue