From 294e73660c1f3d1aff50843c25e2f8f7574c4332 Mon Sep 17 00:00:00 2001 From: toofar Date: Sun, 19 Mar 2023 13:11:12 +1300 Subject: Re-focus tabs created from :undo There's some weird issue with Qt6.4 and 6.5 where a webengine view gets its widget swapped out when it gets history deserialized into it. While it's swapping widgets it has no so the focus gets passed to some other widget should never even have focus. There's probably more comprehensive ways we could handle this, by overriding the WebEngineView layout, or by overriding focusNextPrevChild on the parent to put out own logic into the "child is going, pass focus to parent" logic chain. But all that seems like a bit too much of a headache for this very focussed issue. We want the new tab to get focus, so lets re-focus it. Technically we could just focus the last tab that we open, if we are undoing multiple, but the existing logic is to open each of them in turn as foreground tabs and this reinforces that. Closes: #7623 --- qutebrowser/mainwindow/tabbedbrowser.py | 1 + tests/end2end/features/hints.feature | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index ca6409ba0..770e6a039 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -564,6 +564,7 @@ class TabbedBrowser(QWidget): newtab.history.private_api.deserialize(entry.history) newtab.set_pinned(entry.pinned) + newtab.setFocus() @pyqtSlot('QUrl', bool) def load_url(self, url, newtab): diff --git a/tests/end2end/features/hints.feature b/tests/end2end/features/hints.feature index 47153b741..d6f48a87c 100644 --- a/tests/end2end/features/hints.feature +++ b/tests/end2end/features/hints.feature @@ -620,3 +620,13 @@ Feature: Using hints # Changing tabs will leave hint mode And I wait until qute://pyeval/ is loaded Then the page should contain the plaintext "'Follow hint...'" + + Scenario: Hinting an input after undoing a tab close + When I open about:blank + And I open data/hints/link_input.html in a new tab + And I run :tab-close + And I run :undo + And I wait until data/hints/link_input.html is loaded + And I run :click-element id qute-input-existing + And I run :fake-key -g something + Then the javascript message "contents: existingsomething" should be logged -- cgit v1.2.3-54-g00ecf