mail client (IMAP/SMTP)
git clone https://git.lucas.co/cce-mail.git
fix: Escape closes the search band, not just the query
TextBox consumes Escape itself — clearing and unfocusing — which marked
the event handled before the app's own Escape branch ran. The query
cleared and focus dropped, but the band stayed open forever, and since
the strip belongs to the list when closed, the list never got it back.
Handling it ahead of the box's own routing fixes it. This was invisible
until cce-fx@ddccacb made injected keys reach clients: the band's
keyboard path could not be exercised in a shadow session before, and
this was the first thing the new coverage caught.
Co-Authored-By: Claude Fable 5 <[email protected]>
src/main.rs | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index 55d1e27..18ae8db 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3865,8 +3865,28 @@ impl Application for ClearEmailApp {
handled = true;
}
} else {
+ // Escape closes the search band and drops the query with it, so
+ // the list is unfiltered again — leaving a hidden filter behind
+ // would look like mail had gone missing.
+ //
+ // This runs BEFORE the box is offered the key: TextBox consumes
+ // Escape itself (clearing and unfocusing), which marked the event
+ // handled and left the band standing open forever.
+ if self.search_open
+ && event.state == ElementState::Pressed
+ && event.logical_key == Key::Named(cce_ui::widget::NamedKey::Escape)
+ {
+ ctx.clear_focus();
+ self.search_box.unfocus();
+ self.search_box.text.clear();
+ self.search_box.edit_buffer.clear();
+ self.search_open = false;
+ msg_out = Some(AppMessage::SearchChanged);
+ handled = true;
+ }
+
// General keyboard shortcuts (input.kdl `cce-mail` domain)
- if event.state == ElementState::Pressed {
+ if !handled && event.state == ElementState::Pressed {
if cce_ui::widget::match_key_shortcut(event, &self.keys.compose) {
msg_out = Some(AppMessage::ComposeNew);
handled = true;
@@ -3923,20 +3943,6 @@ impl Application for ClearEmailApp {
}
}
- // Escape closes the search band and drops the query with it, so
- // the list is unfiltered again — leaving a hidden filter behind
- // would look like mail had gone missing.
- if !handled && event.state == ElementState::Pressed && event.logical_key == Key::Named(cce_ui::widget::NamedKey::Escape) {
- if self.search_open {
- ctx.clear_focus();
- self.search_box.unfocus();
- self.search_box.text.clear();
- self.search_box.edit_buffer.clear();
- self.search_open = false;
- msg_out = Some(AppMessage::SearchChanged);
- handled = true;
- }
- }
}
if handled {