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 {
|
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())
|
div().id("my-panel").size_full().child(self.view.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -432,7 +432,6 @@ where
|
||||||
div()
|
div()
|
||||||
.id(self.id.clone())
|
.id(self.id.clone())
|
||||||
.key_context("Dropdown")
|
.key_context("Dropdown")
|
||||||
.group(format!("dropdown-group:{}", self.id))
|
|
||||||
.track_focus(&self.focus_handle)
|
.track_focus(&self.focus_handle)
|
||||||
.on_action(cx.listener(Self::up))
|
.on_action(cx.listener(Self::up))
|
||||||
.on_action(cx.listener(Self::down))
|
.on_action(cx.listener(Self::down))
|
||||||
|
|
@ -440,11 +439,10 @@ where
|
||||||
.on_action(cx.listener(Self::escape))
|
.on_action(cx.listener(Self::escape))
|
||||||
.size_full()
|
.size_full()
|
||||||
.relative()
|
.relative()
|
||||||
|
.input_text_size(self.size)
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.id(ElementId::Name(
|
.id("dropdown-input")
|
||||||
format!("dropdown-input:{}", self.id).into(),
|
|
||||||
))
|
|
||||||
.relative()
|
.relative()
|
||||||
.flex()
|
.flex()
|
||||||
.w_full()
|
.w_full()
|
||||||
|
|
@ -468,7 +466,7 @@ where
|
||||||
.child(div().flex_1().child(self.display_title(cx)))
|
.child(div().flex_1().child(self.display_title(cx)))
|
||||||
.when(show_clean, |this| {
|
.when(show_clean, |this| {
|
||||||
this.child(
|
this.child(
|
||||||
Button::new("clean-text", cx)
|
Button::new("clean", cx)
|
||||||
.icon(IconName::Close)
|
.icon(IconName::Close)
|
||||||
.style(ButtonStyle::Ghost)
|
.style(ButtonStyle::Ghost)
|
||||||
.size(px(14.))
|
.size(px(14.))
|
||||||
|
|
@ -485,7 +483,7 @@ where
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.child(DropdownMenuElement {
|
.child(DropdownMenuElement {
|
||||||
id: ElementId::Name(format!("dropdown-menu:{}", self.id).into()),
|
id: "dropdown-menu".into(),
|
||||||
dropdown: cx.view().clone(),
|
dropdown: cx.view().clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -351,6 +351,7 @@ where
|
||||||
.on_mouse_down(
|
.on_mouse_down(
|
||||||
MouseButton::Left,
|
MouseButton::Left,
|
||||||
cx.listener(move |this, _, cx| {
|
cx.listener(move |this, _, cx| {
|
||||||
|
cx.stop_propagation();
|
||||||
this.selected_index = Some(ix);
|
this.selected_index = Some(ix);
|
||||||
this.action_confirm(&Confirm, cx);
|
this.action_confirm(&Confirm, cx);
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -632,6 +632,8 @@ where
|
||||||
.on_mouse_down(
|
.on_mouse_down(
|
||||||
gpui::MouseButton::Left,
|
gpui::MouseButton::Left,
|
||||||
cx.listener(|_, _, cx| {
|
cx.listener(|_, _, cx| {
|
||||||
|
cx.stop_propagation();
|
||||||
|
|
||||||
PopoverWindowState::close_window(cx);
|
PopoverWindowState::close_window(cx);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,7 @@ impl RenderOnce for Switch {
|
||||||
self.on_click.filter(|_| !self.disabled),
|
self.on_click.filter(|_| !self.disabled),
|
||||||
|this, on_click| {
|
|this, on_click| {
|
||||||
this.on_mouse_down(gpui::MouseButton::Left, move |_, cx| {
|
this.on_mouse_down(gpui::MouseButton::Left, move |_, cx| {
|
||||||
|
cx.stop_propagation();
|
||||||
on_click(&!self.checked, cx);
|
on_click(&!self.checked, cx);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -550,6 +550,7 @@ where
|
||||||
.on_mouse_down(
|
.on_mouse_down(
|
||||||
MouseButton::Left,
|
MouseButton::Left,
|
||||||
cx.listener(move |this, _, cx| {
|
cx.listener(move |this, _, cx| {
|
||||||
|
cx.stop_propagation();
|
||||||
this.on_col_head_click(col_ix, cx);
|
this.on_col_head_click(col_ix, cx);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue