search: auto-focus search field on navigate

I'm going to add a search changelog on this commit since I forgot
to do so previously.

Fixes: https://linear.app/damus/issue/DECK-538/auto-focus-search-field-on-search-view
Changelog-Added: Added fulltext search ui
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-03-07 16:01:55 -08:00
parent 8e0e42a1f3
commit d85c6043b7
5 changed files with 41 additions and 6 deletions

View File

@@ -6,9 +6,22 @@ use std::time::Duration;
pub enum SearchState {
Typing,
Searched,
Navigating,
New,
}
#[derive(Debug, Eq, PartialEq)]
pub enum FocusState {
/// Get ready to focus
Navigating,
/// We should request focus when we stop navigating
ShouldRequestFocus,
/// We already focused, we don't need to do that again
RequestedFocus,
}
/// Search query state that exists between frames
#[derive(Debug)]
pub struct SearchQueryState {
@@ -20,6 +33,10 @@ pub struct SearchQueryState {
/// again next frames
pub state: SearchState,
/// A bit of context to know if we're navigating to the view. We
/// can use this to know when to request focus on the textedit
pub focus_state: FocusState,
/// When was the input updated? We use this to debounce searches
pub debouncer: Debouncer,
@@ -39,6 +56,7 @@ impl SearchQueryState {
string: "".to_string(),
state: SearchState::New,
notes: TimelineTab::default(),
focus_state: FocusState::Navigating,
debouncer: Debouncer::new(Duration::from_millis(200)),
}
}