From 0557d5d099e34f423eec6d9e5c950064831d54b8 Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 30 Sep 2024 02:28:32 +0300 Subject: [PATCH] grab focus to page navigation request on entry is empty --- src/browser/main/tab.rs | 6 +++++- src/browser/main/tab/page.rs | 4 ++++ src/browser/main/tab/page/navigation.rs | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/browser/main/tab.rs b/src/browser/main/tab.rs index 8f52e426..96f6f757 100644 --- a/src/browser/main/tab.rs +++ b/src/browser/main/tab.rs @@ -75,7 +75,7 @@ impl Tab { let label = Arc::new(Label::new(id.clone(), false)); let page = Arc::new(Page::new( id.clone(), - page_navigation_request_text, + page_navigation_request_text.clone(), self.action_tab_page_reload.clone(), self.action_update.clone(), )); @@ -109,6 +109,10 @@ impl Tab { self.widget.set_current_page(Some(page_number)); } + if page_navigation_request_text.is_none() { + page.grab_navigation_request_focus(); + } + // Result page_number } diff --git a/src/browser/main/tab/page.rs b/src/browser/main/tab/page.rs index 782a035b..44af7c01 100644 --- a/src/browser/main/tab/page.rs +++ b/src/browser/main/tab/page.rs @@ -105,6 +105,10 @@ impl Page { } // Actions + pub fn grab_navigation_request_focus(&self) { + self.navigation.grab_request_focus(); + } + pub fn reload(&self) { // Init globals let request_text = self.navigation.request_text(); diff --git a/src/browser/main/tab/page/navigation.rs b/src/browser/main/tab/page/navigation.rs index eb4ac265..3054fbb9 100644 --- a/src/browser/main/tab/page/navigation.rs +++ b/src/browser/main/tab/page/navigation.rs @@ -75,6 +75,10 @@ impl Navigation { } // Actions + pub fn grab_request_focus(&self) { + self.request.widget().grab_focus(); + } + pub fn update(&self, progress_fraction: Option) { self.base.update(self.request.uri()); self.history.update();