Fix dropdown selected icon.

This commit is contained in:
Jason Lee 2024-06-30 19:17:52 +08:00
parent 6503e00b69
commit 29dc803014
2 changed files with 17 additions and 20 deletions

View file

@ -85,36 +85,32 @@ impl ParentElement for ListItem {
impl RenderOnce for ListItem {
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
div()
.id("item-group")
.w_full()
h_flex()
.id("list-item")
.relative()
.gap_x_2()
.items_center()
.justify_between()
.text_base()
.text_color(cx.theme().foreground)
.when_some(self.on_click, |this, on_click| {
this.cursor_pointer().on_click(on_click)
})
.when(self.selected, |this| this.bg(cx.theme().accent))
.when(!self.selected, |this| {
this.hover(|this| this.bg(cx.theme().accent))
})
// Right click
.when_some(self.on_secondary_mouse_down, |this, on_mouse_down| {
this.on_mouse_down(MouseButton::Right, move |ev, cx| (on_mouse_down)(ev, cx))
})
.when(self.selected, |this| this.bg(cx.theme().accent))
.child(
self.base
.when(!self.selected, |this| {
this.hover(|this| this.bg(cx.theme().accent))
})
.w_full()
.items_center()
.justify_between()
.when(self.selected, |this| {
if let Some(icon) = self.check_icon {
this.child(icon.text_color(cx.theme().muted))
} else {
this
}
}),
)
.child(self.base.w_full())
.when(self.selected, |this| {
if let Some(icon) = self.check_icon {
this.child(icon.text_color(cx.theme().muted_foreground).mr_2())
} else {
this
}
})
}
}

View file

@ -508,6 +508,7 @@ impl<D: PickerDelegate> Render for Picker<D> {
el.child(
v_flex()
.flex_grow()
.min_h(px(100.))
.when_some(self.max_height, |div, max_h| div.max_h(max_h))
.overflow_hidden()
.child(self.render_element_container(cx)),