Repository: aome510/spotify-player (language: rust)

Issue:
Pressing `delete` on an empty Search should close it
**Is your feature already implemented in the latest `master`?**
no

**Is your feature request related to a problem? Please describe.**
Currently, you need to press `esc` to close a Search. my reflex is to always empty the Search with expectation that it would close eventually after it has been empty

**Describe the solution you'd like**
title. additionally, a split-second delay between Search being emptied and closed while `delete` is still pressed might help wrongly closed Search

**Describe alternatives you've considered**


**Additional context**




Discussion / hints:

Fix patch:
diff --git a/spotify_player/src/event/popup.rs b/spotify_player/src/event/popup.rs
index f578c831..86594040 100644
--- a/spotify_player/src/event/popup.rs
+++ b/spotify_player/src/event/popup.rs
@@ -298,6 +298,9 @@ fn handle_key_sequence_for_search_popup(
                     if !query.is_empty() {
                         query.pop().unwrap();
                         ui.current_page_mut().select(0);
+                    } else {
+                        // close search popup when user presses backspace on empty search
+                        ui.popup = None;
                     }
                     return Ok(true);
                 }
diff --git a/spotify_player/src/state/ui/mod.rs b/spotify_player/src/state/ui/mod.rs
index 96c4c246..0a52a46e 100644
--- a/spotify_player/src/state/ui/mod.rs
+++ b/spotify_player/src/state/ui/mod.rs
@@ -96,7 +96,10 @@ impl UIState {
                             true
                         } else {
                             let t = t.to_string().to_lowercase();
-                            query.split(' ').any(|q| !q.is_empty() && t.contains(q))
+                            query
+                                .split(' ')
+                                .filter(|q| !q.is_empty())
+                                .all(|q| t.contains(q))
                         }
                     })
                     .collect::<Vec<_>>()


Test patch: