From 827b16bf5c7ec811aaf719b4870fc1ddd91e3891 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 13 Nov 2023 14:42:16 +0100 Subject: [PATCH] Capture node in dispatch tree even if it's not focusable --- crates/gpui2/src/key_dispatch.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/gpui2/src/key_dispatch.rs b/crates/gpui2/src/key_dispatch.rs index 40d6c66973..6dac90fc59 100644 --- a/crates/gpui2/src/key_dispatch.rs +++ b/crates/gpui2/src/key_dispatch.rs @@ -305,7 +305,7 @@ pub trait KeyDispatch: 'static { cx: &mut ViewContext, f: impl FnOnce(Option, &mut ViewContext) -> R, ) -> R { - if let Some(focusable) = self.as_focusable_mut() { + let focus_handle = if let Some(focusable) = self.as_focusable_mut() { let focus_handle = focusable .focus_handle .get_or_insert_with(|| focus_handle.unwrap_or_else(|| cx.focus_handle())) @@ -316,11 +316,12 @@ pub trait KeyDispatch: 'static { listener(view, &focus_handle, event, cx) }); } - - cx.with_key_dispatch(self.key_context().clone(), Some(focus_handle), f) + Some(focus_handle) } else { - f(None, cx) - } + None + }; + + cx.with_key_dispatch(self.key_context().clone(), focus_handle, f) } fn refine_style(&self, style: &mut Style, cx: &WindowContext) {