diff --git a/src/app/browser/window/tab/item/page/search/form.rs b/src/app/browser/window/tab/item/page/search/form.rs index 2bdf1e95..573f2775 100644 --- a/src/app/browser/window/tab/item/page/search/form.rs +++ b/src/app/browser/window/tab/item/page/search/form.rs @@ -63,11 +63,12 @@ impl Form { input.entry.text().as_str(), match_case.is_active(), ); - if !this.text().is_empty() && !matches.is_empty() { - result.show(0, matches.len()); + if !this.text().is_empty() { + result.update(0, matches.len()); + result.label.set_visible(true); separator.set_visible(true); } else { - result.hide(); + result.label.set_visible(false); separator.set_visible(false); } input.update(!matches.is_empty()); @@ -92,12 +93,21 @@ impl Form { let input = input.clone(); let navigation = navigation.clone(); let subject = subject.clone(); + let input = input.clone(); move |this| { let matches = find( subject.borrow().as_ref().unwrap(), // @TODO handle input.entry.text().as_str(), this.is_active(), ); + if !input.entry.text().is_empty() { + result.update(0, matches.len()); + result.label.set_visible(true); + separator.set_visible(true); + } else { + result.label.set_visible(false); + separator.set_visible(false); + } input.update(!matches.is_empty()); navigation.update(matches); } diff --git a/src/app/browser/window/tab/item/page/search/form/result.rs b/src/app/browser/window/tab/item/page/search/form/result.rs index d61a1a7f..e9939152 100644 --- a/src/app/browser/window/tab/item/page/search/form/result.rs +++ b/src/app/browser/window/tab/item/page/search/form/result.rs @@ -22,7 +22,7 @@ impl Result { // Actions - pub fn show(&self, current: usize, total: usize) { + pub fn update(&self, current: usize, total: usize) { if total > 0 { self.label .set_label(&format!("{current} if {total} matches")); @@ -31,10 +31,5 @@ impl Result { self.label.set_label(&format!("Phrase not found")); self.label.add_css_class("error"); } - self.label.set_visible(true); - } - - pub fn hide(&self) { - self.label.set_visible(false); } }