refactor
This commit is contained in:
@@ -157,16 +157,15 @@ impl RenderOnce for Dialog {
|
||||
let alert = self.alert;
|
||||
|
||||
// Keyboard focus rides the panel across frames.
|
||||
let focus_handle = window.use_keyed_state("dialog-focus", cx, |_, cx| cx.focus_handle());
|
||||
let focus = gpui_native_utils::focus_handle(&self.id, window, cx);
|
||||
|
||||
let content = self.content.map(|build| build(window, cx));
|
||||
let actions = self.actions.map(|build| build(window, cx));
|
||||
|
||||
let panel_bounds: BoundsCell = Rc::new(RefCell::new(None));
|
||||
|
||||
let panel = v_flex()
|
||||
.id("dialog-panel")
|
||||
.track_focus(&focus_handle.read(cx).clone())
|
||||
.track_focus(&focus)
|
||||
.role(role)
|
||||
.aria_label(label)
|
||||
.min_w_64()
|
||||
@@ -214,11 +213,9 @@ impl RenderOnce for Dialog {
|
||||
move |bounds, _window, _cx| *cell.borrow_mut() = Some(bounds)
|
||||
},
|
||||
{
|
||||
let focus_handle = focus_handle.clone();
|
||||
move |_, _, window, cx| {
|
||||
let handle = focus_handle.read(cx).clone();
|
||||
if !handle.contains_focused(window, cx) {
|
||||
window.focus(&handle, cx);
|
||||
if !focus.contains_focused(window, cx) {
|
||||
window.focus(&focus, cx);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user