documents: an open block stays open while an overlay borrows focus
CI / platforms (windows-latest) (push) Failing after 12s
CI / site (push) Successful in 21s
CI / crate (push) Failing after 11m41s
CI / platforms (ubuntu-24.04) (push) Canceled after 0s

A menu or dialog took focus, the open block wrote back and closed, and
the overlay handed focus back to a closed input: its command reached
nothing and the selection was gone. The block now waits for the overlay
to let focus go, and writes back only when focus lands elsewhere.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-14 17:01:42 -04:00
1 parent 6b033f3eb0
commit 6d90351423
7 files changed
+150 -15

No files matched your search

+8
View File
@@ -210,6 +210,14 @@ pub(crate) fn take_focus(
state
}
/// Whether an open overlay holds the window's focus.
pub(crate) fn lent(window: &Window, cx: &App) -> bool {
cx.try_global::<Holders>().is_some_and(|holders| {
(holders.0.iter())
.any(|holder| holder.takeover.upgrade().is_some() && holder.focus.is_focused(window))
})
}
/// Returns focus to whatever held it before the overlay opened.
pub(crate) fn give_back(state: &Entity<Takeover>, window: &mut Window, cx: &mut App) {
let closed = state.downgrade();
+2 -1
View File
@@ -25,7 +25,8 @@ pub use divider::Divider;
pub use files::IconTheme;
pub(crate) use files::{file_icon, icon_theme};
pub(crate) use focus::{
CONTEXT as FOCUS_CONTEXT, Takeover, give_back, hand_back, hold_focus, tab_stop, take_focus,
CONTEXT as FOCUS_CONTEXT, Takeover, give_back, hand_back, hold_focus, lent, tab_stop,
take_focus,
};
pub use focus::{FocusNext, FocusPrev, FocusRing, FocusScope};
pub use ghost::DragGhost;