This bug was caused by #1545.
This commit is contained in:
parent
3cd94ea0be
commit
a185d8ed24
2 changed files with 18 additions and 16 deletions
|
|
@ -89,6 +89,7 @@ where
|
||||||
|
|
||||||
Popover::new(SharedString::from(format!("popover:{}", self.id)))
|
Popover::new(SharedString::from(format!("popover:{}", self.id)))
|
||||||
.appearance(false)
|
.appearance(false)
|
||||||
|
.overlay_closable(false)
|
||||||
.trigger(self.trigger)
|
.trigger(self.trigger)
|
||||||
.trigger_style(self.style)
|
.trigger_style(self.style)
|
||||||
.anchor(self.anchor)
|
.anchor(self.anchor)
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ pub struct Popover {
|
||||||
trigger_style: Option<StyleRefinement>,
|
trigger_style: Option<StyleRefinement>,
|
||||||
mouse_button: MouseButton,
|
mouse_button: MouseButton,
|
||||||
appearance: bool,
|
appearance: bool,
|
||||||
|
overlay_closable: bool,
|
||||||
on_open_change: Option<Rc<dyn Fn(&bool, &mut Window, &mut App)>>,
|
on_open_change: Option<Rc<dyn Fn(&bool, &mut Window, &mut App)>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,6 +53,7 @@ impl Popover {
|
||||||
children: vec![],
|
children: vec![],
|
||||||
mouse_button: MouseButton::Left,
|
mouse_button: MouseButton::Left,
|
||||||
appearance: true,
|
appearance: true,
|
||||||
|
overlay_closable: true,
|
||||||
default_open: false,
|
default_open: false,
|
||||||
open: None,
|
open: None,
|
||||||
on_open_change: None,
|
on_open_change: None,
|
||||||
|
|
@ -121,6 +123,12 @@ impl Popover {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set whether clicking outside the popover will dismiss it, default is `true`.
|
||||||
|
pub fn overlay_closable(mut self, closable: bool) -> Self {
|
||||||
|
self.overlay_closable = closable;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the content builder for content of the Popover.
|
/// Set the content builder for content of the Popover.
|
||||||
///
|
///
|
||||||
/// This callback will called every time on render the popover.
|
/// This callback will called every time on render the popover.
|
||||||
|
|
@ -373,24 +381,17 @@ impl RenderOnce for Popover {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.children(self.children)
|
.children(self.children)
|
||||||
.when(self.appearance, |this| {
|
.when(self.overlay_closable, |this| {
|
||||||
let state = state.clone();
|
this.on_mouse_down_out({
|
||||||
this.on_mouse_down_out(move |_, window, cx| {
|
let state = state.clone();
|
||||||
state.update(cx, |state, cx| {
|
move |_, window, cx| {
|
||||||
state.toggle_open(window, cx);
|
state.update(cx, |state, cx| {
|
||||||
});
|
state.dismiss(window, cx);
|
||||||
cx.notify(parent_view_id);
|
});
|
||||||
|
cx.notify(parent_view_id);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.on_mouse_down_out({
|
|
||||||
let state = state.clone();
|
|
||||||
move |_, window, cx| {
|
|
||||||
state.update(cx, |state, cx| {
|
|
||||||
state.dismiss(window, cx);
|
|
||||||
});
|
|
||||||
cx.notify(parent_view_id);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.refine_style(&self.style),
|
.refine_style(&self.style),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue