forked from reya/gpui-native-kit
refactor
This commit is contained in:
@@ -161,15 +161,12 @@ impl RenderOnce for Popover {
|
||||
if self.open {
|
||||
let on_change = self.on_change;
|
||||
let label = fallback_label.clone();
|
||||
|
||||
let focus_handle =
|
||||
window.use_keyed_state("popover-focus", cx, |_, cx| cx.focus_handle());
|
||||
|
||||
let focus = gpui_native_utils::focus_handle(&self.id, window, cx);
|
||||
let content = self.content.map(|content| content(window, cx));
|
||||
|
||||
let panel = v_flex()
|
||||
.id("popover-panel")
|
||||
.track_focus(&focus_handle.read(cx).clone())
|
||||
.track_focus(&focus)
|
||||
.role(Role::Dialog)
|
||||
.aria_label(label)
|
||||
.mt_1()
|
||||
@@ -201,12 +198,11 @@ impl RenderOnce for Popover {
|
||||
},
|
||||
{
|
||||
let on_change = on_change.clone();
|
||||
let focus = focus_handle;
|
||||
let focus = focus;
|
||||
move |_, _, window, cx| {
|
||||
if !focus.read(cx).contains_focused(window, cx) {
|
||||
window.focus(&focus.read(cx).clone(), cx);
|
||||
if !focus.contains_focused(window, cx) {
|
||||
window.focus(&focus, cx);
|
||||
}
|
||||
|
||||
window.on_mouse_event({
|
||||
let on_change = on_change.clone();
|
||||
move |event: &MouseDownEvent, phase, window, cx| {
|
||||
|
||||
Reference in New Issue
Block a user