diff options
| author | Pan Zhang <[email protected]> | 2026-03-16 16:23:55 +0800 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2026-03-17 09:40:37 +0000 |
| commit | 35b309aa3efac59b12e0c6bfc127516649f8cfa2 (patch) | |
| tree | cb160719bcf4305c9ef62c7d8338abb35c717f91 /src/search | |
| parent | 063b31f1643d27e95c0bfee5ccdcd649d9df0cb5 (diff) | |
dolphinviewcontainer: Avoid adding an extra history entry when leaving search results
When navigating away from a search result, hiding the search bar unintentionally emitted urlChangeRequested(searchPath). This inserted an extra navigation step into the history, causing the “Back” button to require multiple presses to return to the search results.
Introduce Search::Bar::HideBehavior to allow callers to hide the search bar without triggering a URL change, and use it when the bar is automatically hidden due to non-search navigation.
BUG: 515236
Diffstat (limited to 'src/search')
| -rw-r--r-- | src/search/bar.cpp | 6 | ||||
| -rw-r--r-- | src/search/bar.h | 15 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/search/bar.cpp b/src/search/bar.cpp index 851eef942..7e31cb0f2 100644 --- a/src/search/bar.cpp +++ b/src/search/bar.cpp @@ -187,11 +187,13 @@ void Bar::selectAll() m_searchTermEditor->selectAll(); } -void Bar::setVisible(bool visible, Animated animated) +void Bar::setVisible(bool visible, Animated animated, HideBehavior hideBehavior) { if (!visible) { m_startSearchTimer->stop(); - Q_EMIT urlChangeRequested(m_searchConfiguration->searchPath()); + if (hideBehavior == HideBehavior::RestoreUrl) { + Q_EMIT urlChangeRequested(m_searchConfiguration->searchPath()); + } if (isAncestorOf(QApplication::focusWidget())) { Q_EMIT focusViewRequest(); } diff --git a/src/search/bar.h b/src/search/bar.h index 969335232..1017d813f 100644 --- a/src/search/bar.h +++ b/src/search/bar.h @@ -51,6 +51,19 @@ class Bar : public AnimatedHeightWidget, public UpdatableStateInterface Q_OBJECT public: + enum class HideBehavior { + /** + * When hiding the bar, request that the view switches back to a non-search URL (the search path). + * This is the behavior when the user explicitly quits searching. + */ + RestoreUrl, + /** + * When hiding the bar, do not request any URL change. + * This is used when the UI is hidden automatically because the view navigated elsewhere already. + */ + KeepCurrentUrl, + }; + /** * @brief Constructs a Search::Bar with an initial state matching @p dolphinQuery and with parent @p parent. */ @@ -80,7 +93,7 @@ public: * be properly un/checked. * @see AnimatedHeightWidget::setVisible(). */ - void setVisible(bool visible, Animated animated); + void setVisible(bool visible, Animated animated, HideBehavior hideBehavior = HideBehavior::RestoreUrl); /** * @returns false, when the search UI has not yet been changed to search for anything specific. For example when no search term has been entered yet. |
