diff options
| -rw-r--r-- | src/dolphinmainwindow.cpp | 2 | ||||
| -rw-r--r-- | src/tests/dolphinmainwindowtest.cpp | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index ead46de30..e52494c0a 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1563,6 +1563,8 @@ void DolphinMainWindow::slotPlaceActivated(const QUrl &url) // We can end up here if the user clicked a device in the Places Panel // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385. reloadView(); + + m_activeViewContainer->view()->setFocus(); // We always want the focus on the view after activating a place. } else { view->disableUrlNavigatorSelectionRequests(); changeUrl(url); diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp index cd68bb893..6ac85e4f0 100644 --- a/src/tests/dolphinmainwindowtest.cpp +++ b/src/tests/dolphinmainwindowtest.cpp @@ -456,6 +456,18 @@ void DolphinMainWindowTest::testFocusPlacesPanel() showPlacesPanelAction->trigger(); QVERIFY(placesPanel->isVisible()); QVERIFY2(placesPanel->hasFocus(), "Enabling the Places panel should move keyboard focus there."); + + /// Test that activating a place always moves focus to the view. + QTest::keyClick(QApplication::focusWidget(), Qt::Key::Key_Enter); + QVERIFY2(m_mainWindow->activeViewContainer()->isAncestorOf(QApplication::focusWidget()), + "Activating a place should move focus to the view that loads that place."); + + focusPlacesPanelAction->trigger(); + QVERIFY(placesPanel->hasFocus()); + + QTest::keyClick(QApplication::focusWidget(), Qt::Key::Key_Enter); + QVERIFY2(m_mainWindow->activeViewContainer()->isAncestorOf(QApplication::focusWidget()), + "Activating a place should move focus to the view even if the view already has that place loaded."); } /** |
