Fix dropdown click to lose focus. (#80)
This commit is contained in:
parent
6e58edd349
commit
8aaeb9383d
6 changed files with 10 additions and 7 deletions
|
|
@ -306,7 +306,7 @@ impl FocusableView for MyPanel {
|
|||
}
|
||||
}
|
||||
impl Render for MyPanel {
|
||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
|
||||
fn render(&mut self, _: &mut ViewContext<Self>) -> impl IntoElement {
|
||||
div().id("my-panel").size_full().child(self.view.clone())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -432,7 +432,6 @@ where
|
|||
div()
|
||||
.id(self.id.clone())
|
||||
.key_context("Dropdown")
|
||||
.group(format!("dropdown-group:{}", self.id))
|
||||
.track_focus(&self.focus_handle)
|
||||
.on_action(cx.listener(Self::up))
|
||||
.on_action(cx.listener(Self::down))
|
||||
|
|
@ -440,11 +439,10 @@ where
|
|||
.on_action(cx.listener(Self::escape))
|
||||
.size_full()
|
||||
.relative()
|
||||
.input_text_size(self.size)
|
||||
.child(
|
||||
div()
|
||||
.id(ElementId::Name(
|
||||
format!("dropdown-input:{}", self.id).into(),
|
||||
))
|
||||
.id("dropdown-input")
|
||||
.relative()
|
||||
.flex()
|
||||
.w_full()
|
||||
|
|
@ -468,7 +466,7 @@ where
|
|||
.child(div().flex_1().child(self.display_title(cx)))
|
||||
.when(show_clean, |this| {
|
||||
this.child(
|
||||
Button::new("clean-text", cx)
|
||||
Button::new("clean", cx)
|
||||
.icon(IconName::Close)
|
||||
.style(ButtonStyle::Ghost)
|
||||
.size(px(14.))
|
||||
|
|
@ -485,7 +483,7 @@ where
|
|||
),
|
||||
)
|
||||
.child(DropdownMenuElement {
|
||||
id: ElementId::Name(format!("dropdown-menu:{}", self.id).into()),
|
||||
id: "dropdown-menu".into(),
|
||||
dropdown: cx.view().clone(),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -351,6 +351,7 @@ where
|
|||
.on_mouse_down(
|
||||
MouseButton::Left,
|
||||
cx.listener(move |this, _, cx| {
|
||||
cx.stop_propagation();
|
||||
this.selected_index = Some(ix);
|
||||
this.action_confirm(&Confirm, cx);
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -632,6 +632,8 @@ where
|
|||
.on_mouse_down(
|
||||
gpui::MouseButton::Left,
|
||||
cx.listener(|_, _, cx| {
|
||||
cx.stop_propagation();
|
||||
|
||||
PopoverWindowState::close_window(cx);
|
||||
}),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ impl RenderOnce for Switch {
|
|||
self.on_click.filter(|_| !self.disabled),
|
||||
|this, on_click| {
|
||||
this.on_mouse_down(gpui::MouseButton::Left, move |_, cx| {
|
||||
cx.stop_propagation();
|
||||
on_click(&!self.checked, cx);
|
||||
})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -550,6 +550,7 @@ where
|
|||
.on_mouse_down(
|
||||
MouseButton::Left,
|
||||
cx.listener(move |this, _, cx| {
|
||||
cx.stop_propagation();
|
||||
this.on_col_head_click(col_ix, cx);
|
||||
}),
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue