From ceeadab6ef92299e65901c2320a6e07f2a4d1913 Mon Sep 17 00:00:00 2001 From: Robert Saternus Date: Tue, 10 Dec 2024 10:57:20 +0100 Subject: [PATCH] FFWEB-3253: Remove multiple redirect to search result page Don't redirect to search result page if search in executed already on result page --- CHANGELOG.md | 4 ++++ src/Resources/views/storefront/base.html.twig | 14 ++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cffd7169..6391b61f 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Changelog +## Unreleased +### Fix +- Don't redirect to search result page if search is executed already on result page + ## [v6.0.1] - 2024.11.21 ### Improve - Add the ability to set a name for the CategoryPath field (category page) diff --git a/src/Resources/views/storefront/base.html.twig b/src/Resources/views/storefront/base.html.twig index f3a98733..b97f9068 100644 --- a/src/Resources/views/storefront/base.html.twig +++ b/src/Resources/views/storefront/base.html.twig @@ -36,12 +36,14 @@ return; } - if (searchOptions?.requestOptions?.origin?.tagName === `FF-SEARCHBOX`) { - window.location.href = `/factfinder/result?query=${searchParams.query}`; - - // Cancel the pipeline to avoid sending a search request to FactFinder before the redirect is complete. - return false; - } + {% if app.request.pathInfo !== "/factfinder/result" %} + if (searchOptions?.requestOptions?.origin?.tagName === `FF-SEARCHBOX`) { + window.location.href = `/factfinder/result?query=${searchParams.query}`; + + // Cancel the pipeline to avoid sending a search request to FactFinder before the redirect is complete. + return false; + } + {% endif %} }); {% if page.extensions.factfinder.searchImmediate and not page.extensions.factfinder.ssr %}