From 373d97ddf0c575cd40ad7c6bd9dcac66407da00b Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 22 Apr 2025 18:54:07 +0800 Subject: [PATCH] root: Fix to reset focused_input when close modal or drawer. (#807) --- crates/ui/src/root.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/ui/src/root.rs b/crates/ui/src/root.rs index 6a7cceaa..93e66baa 100644 --- a/crates/ui/src/root.rs +++ b/crates/ui/src/root.rs @@ -91,6 +91,7 @@ impl ContextModal for Window { fn close_drawer(&mut self, cx: &mut App) { Root::update(self, cx, |root, window, cx| { + root.focused_input = None; root.active_drawer = None; root.focus_back(window, cx); cx.notify(); @@ -125,6 +126,7 @@ impl ContextModal for Window { fn close_modal(&mut self, cx: &mut App) { Root::update(self, cx, move |root, window, cx| { + root.focused_input = None; root.active_modals.pop(); if let Some(top_modal) = root.active_modals.last() { @@ -140,6 +142,7 @@ impl ContextModal for Window { fn close_all_modals(&mut self, cx: &mut App) { Root::update(self, cx, |root, window, cx| { + root.focused_input = None; root.active_modals.clear(); root.focus_back(window, cx); cx.notify();