diff --git a/bin/commands/inbox/select/ui.rs b/bin/commands/inbox/select/ui.rs index 98612bf0..2248546a 100644 --- a/bin/commands/inbox/select/ui.rs +++ b/bin/commands/inbox/select/ui.rs @@ -172,12 +172,10 @@ impl Browser { }), search: TextField::default() .to_widget(tx.clone()) - .on_event(|key, s, _| match key { - Key::Esc => Some(Message::CloseSearch), - Key::Char('\n') => Some(Message::ApplySearch), - _ => Some(Message::UpdateSearch { + .on_event(|_, s, _| { + Some(Message::UpdateSearch { value: s.and_then(|i| i.unwrap_string()).unwrap_or_default(), - }), + }) }) .on_update(|state: &State| { TextFieldProps::default() @@ -202,8 +200,17 @@ impl View for Browser { .unwrap_or(&default); if props.show_search { - self.search.handle_event(key); - None + match key { + Key::Esc => { + self.search.reset(); + Some(Message::CloseSearch) + } + Key::Char('\n') => Some(Message::ApplySearch), + _ => { + self.search.handle_event(key); + None + } + } } else { match key { Key::Char('/') => Some(Message::OpenSearch), diff --git a/bin/commands/issue/select/ui.rs b/bin/commands/issue/select/ui.rs index 3a9178fb..2428c29d 100644 --- a/bin/commands/issue/select/ui.rs +++ b/bin/commands/issue/select/ui.rs @@ -187,12 +187,10 @@ impl Browser { }), search: TextField::default() .to_widget(tx.clone()) - .on_event(|key, s, _| match key { - Key::Esc => Some(Message::CloseSearch), - Key::Char('\n') => Some(Message::ApplySearch), - _ => Some(Message::UpdateSearch { + .on_event(|_, s, _| { + Some(Message::UpdateSearch { value: s.and_then(|i| i.unwrap_string()).unwrap_or_default(), - }), + }) }) .on_update(|state: &State| { TextFieldProps::default() @@ -217,8 +215,17 @@ impl View for Browser { .unwrap_or(&default); if props.show_search { - self.search.handle_event(key); - None + match key { + Key::Esc => { + self.search.reset(); + Some(Message::CloseSearch) + } + Key::Char('\n') => Some(Message::ApplySearch), + _ => { + self.search.handle_event(key); + None + } + } } else { match key { Key::Char('/') => Some(Message::OpenSearch), diff --git a/bin/commands/patch/select/ui.rs b/bin/commands/patch/select/ui.rs index cca7bb64..cf8ee534 100644 --- a/bin/commands/patch/select/ui.rs +++ b/bin/commands/patch/select/ui.rs @@ -189,12 +189,10 @@ impl Browser { }), search: TextField::default() .to_widget(tx.clone()) - .on_event(|key, s, _| match key { - Key::Esc => Some(Message::CloseSearch), - Key::Char('\n') => Some(Message::ApplySearch), - _ => Some(Message::UpdateSearch { + .on_event(|_, s, _| { + Some(Message::UpdateSearch { value: s.and_then(|i| i.unwrap_string()).unwrap_or_default(), - }), + }) }) .on_update(|state: &State| { TextFieldProps::default() @@ -219,8 +217,17 @@ impl View for Browser { .unwrap_or(&default); if props.show_search { - self.search.handle_event(key); - None + match key { + Key::Esc => { + self.search.reset(); + Some(Message::CloseSearch) + } + Key::Char('\n') => Some(Message::ApplySearch), + _ => { + self.search.handle_event(key); + None + } + } } else { match key { Key::Esc | Key::Ctrl('c') => Some(Message::Exit { selection: None }),