diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index 2d674e280..28c754a97 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -487,6 +487,8 @@ class TabbedBrowser(QWidget): tab.resize(self.widget.currentWidget().size()) self.widget.tab_index_changed.emit(self.widget.currentIndex(), self.widget.count()) + # Refocus webview in case we lost it by spawning a bg tab + self.widget.currentWidget().setFocus() else: self.widget.setCurrentWidget(tab) # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-68076 diff --git a/tests/end2end/features/hints.feature b/tests/end2end/features/hints.feature index 7805082ad..c3b857bc4 100644 --- a/tests/end2end/features/hints.feature +++ b/tests/end2end/features/hints.feature @@ -203,17 +203,6 @@ Feature: Using hints And I run :fake-key new Then the javascript message "contents: existingnew" should be logged - Scenario: Typing input with existing text after opening a bg tab - When I open data/hints/link_input.html - And I run :click-element id qute-input-existing - And I wait for "Entering mode KeyMode.insert *" in the log - And I run :leave-mode - And I hint with args "all tab-bg" and follow a - And I wait until data/hello.txt is loaded - And I run :enter-mode insert - And I run :fake-key -g new - Then the javascript message "contents: existingnew" should be logged - ### iframes Scenario: Using :follow-hint inside an iframe When I open data/hints/iframe.html diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index 1841ef9c9..a19bc7a97 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -1250,3 +1250,25 @@ Feature: Tab management Then the following tabs should be open: - data/numbers/1.txt - data/numbers/2.txt (pinned) (active) + + + Scenario: Focused webview after clicking link in bg + When I open data/hints/link_input.html + And I run :click-element id qute-input-existing + And I wait for "Entering mode KeyMode.insert *" in the log + And I run :leave-mode + And I hint with args "all tab-bg" and follow a + And I wait until data/hello.txt is loaded + And I run :enter-mode insert + And I run :fake-key -g new + Then the javascript message "contents: existingnew" should be logged + + Scenario: Focused webview after opening link in bg + When I open data/hints/link_input.html + And I run :click-element id qute-input-existing + And I wait for "Entering mode KeyMode.insert *" in the log + And I run :leave-mode + And I open data/hello.txt in a new background tab + And I run :enter-mode insert + And I run :fake-key -g new + Then the javascript message "contents: existingnew" should be logged