refactor
This commit is contained in:
@@ -305,7 +305,7 @@ impl RenderOnce for Menu {
|
||||
};
|
||||
|
||||
// Keyboard focus rides the panel across frames.
|
||||
let focus_handle = window.use_keyed_state("menu-focus", cx, |_, cx| cx.focus_handle());
|
||||
let focus = gpui_native_utils::focus_handle(&self.id, window, cx);
|
||||
let scroll = window.use_keyed_state("menu-scroll", cx, |_, _| ScrollHandle::new());
|
||||
|
||||
let selected = if *was_open.read(cx) {
|
||||
@@ -334,7 +334,7 @@ impl RenderOnce for Menu {
|
||||
|
||||
let panel = v_flex()
|
||||
.id("menu-panel")
|
||||
.track_focus(&focus_handle.read(cx).clone())
|
||||
.track_focus(&focus)
|
||||
.role(Role::Menu)
|
||||
.aria_label(label)
|
||||
.mt_1()
|
||||
@@ -371,10 +371,9 @@ impl RenderOnce for Menu {
|
||||
},
|
||||
{
|
||||
let on_change = on_change.clone();
|
||||
let focus = focus_handle;
|
||||
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({
|
||||
|
||||
Reference in New Issue
Block a user