Skip to content

queryParamsString never gets assigned to the resultUrl #326

@Gerke-W

Description

@Gerke-W

Removal of parameter assigning in view/frontend/web/js/navigation-form.js causing issues

In version 8.7.0 the assignment of queryParamsString to resultUrl.search = queryParamsString; has been removed. As a result the changes that happen to queryParamsString are not applied and url's with additional parameters like UTM tags are removed on initial page load.

_buildUrlWithQueryString: function (response, flip = false) {
            const baseUrl = window.location.origin;
            const resultUrl = new URL(response.url, baseUrl);
            const queryParams = new URLSearchParams(window.location.search ?? '');

            if (!resultUrl.searchParams.has('p')) {
                queryParams.delete('p');
            }

            let queryParamsString = queryParams.toString();

            if (resultUrl.search) {
                if (flip) {
                    queryParamsString = this._combineQueryStrings(resultUrl.searchParams, queryParams);
                } else {
                    queryParamsString = this._combineQueryStrings(queryParams, resultUrl.searchParams);
                }
            }

            <-- Was initially here, see [8.7.0](https://github.com/EmicoEcommerce/Magento2Tweakwise/blob/v8.7.0/view/frontend/web/js/navigation-form.js)  -->
            let result = resultUrl.toString();
            result = this._normalizeQueryString(result);

            return result;
        },

Patch:

Index: vendor/tweakwise/magento2-tweakwise/view/frontend/web/js/navigation-form.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/vendor/tweakwise/magento2-tweakwise/view/frontend/web/js/navigation-form.js b/vendor/tweakwise/magento2-tweakwise/view/frontend/web/js/navigation-form.js
--- a/vendor/tweakwise/magento2-tweakwise/view/frontend/web/js/navigation-form.js
+++ b/vendor/tweakwise/magento2-tweakwise/view/frontend/web/js/navigation-form.js	(date 1763565549899)
@@ -480,6 +480,7 @@
                 }
             }

+            resultUrl.search = queryParamsString;
             let result = resultUrl.toString();
             result = this._normalizeQueryString(result);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions