From 9a84e2170e8a08808d1887b44cb4716c72ffe2f0 Mon Sep 17 00:00:00 2001
From: Andrea Delgado <114981520+andreadlgdo@users.noreply.github.com>
Date: Mon, 8 Jul 2024 12:04:16 +0200
Subject: [PATCH 1/6] feat: migrate url-handler
---
.../x-modules/url/components/url-handler.vue | 666 +++++++++---------
.../src/x-modules/url/x-module.ts | 3 +
2 files changed, 339 insertions(+), 330 deletions(-)
diff --git a/packages/x-components/src/x-modules/url/components/url-handler.vue b/packages/x-components/src/x-modules/url/components/url-handler.vue
index 650bdcf666..9bf259c7cb 100644
--- a/packages/x-components/src/x-modules/url/components/url-handler.vue
+++ b/packages/x-components/src/x-modules/url/components/url-handler.vue
@@ -4,12 +4,8 @@
diff --git a/packages/x-components/src/x-modules/url/x-module.ts b/packages/x-components/src/x-modules/url/x-module.ts
index fba725a3bd..d3790fa420 100644
--- a/packages/x-components/src/x-modules/url/x-module.ts
+++ b/packages/x-components/src/x-modules/url/x-module.ts
@@ -1,4 +1,5 @@
import { XModule } from '../x-modules.types';
+import { XPlugin } from '../../plugins/index';
import { urlEmitters, urlXStoreModule, UrlXStoreModule } from './store';
import { urlWiring } from './wiring';
@@ -21,3 +22,5 @@ export const urlXModule: UrlXModule = {
storeEmitters: urlEmitters,
wiring: urlWiring
};
+
+XPlugin.registerXModule(urlXModule);
From fb231e685899541c606bff79a9758b333bdc650e Mon Sep 17 00:00:00 2001
From: Andrea Delgado <114981520+andreadlgdo@users.noreply.github.com>
Date: Mon, 8 Jul 2024 13:08:38 +0200
Subject: [PATCH 2/6] fix: add url line
---
.../src/x-modules/url/components/url-handler.vue | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/packages/x-components/src/x-modules/url/components/url-handler.vue b/packages/x-components/src/x-modules/url/components/url-handler.vue
index 9bf259c7cb..20b3bb41ff 100644
--- a/packages/x-components/src/x-modules/url/components/url-handler.vue
+++ b/packages/x-components/src/x-modules/url/components/url-handler.vue
@@ -169,15 +169,16 @@
historyMethod: History['pushState'] | History['replaceState']
): void => {
if (urlLoaded.value) {
- const url = new URL(window.location.href);
- deleteUrlParameters(url);
- setUrlParameters(url, newUrlParams);
+ const newUrl = new URL(window.location.href);
+ deleteUrlParameters(newUrl);
+ setUrlParameters(newUrl, newUrlParams);
- url.href = url.href.replace(/\+/g, '%20');
+ newUrl.href = newUrl.href.replace(/\+/g, '%20');
- if (url.href !== window.location.href) {
- historyMethod({ ...window.history.state }, document.title, url.href);
+ if (newUrl.href !== window.location.href) {
+ historyMethod({ ...window.history.state }, document.title, newUrl.href);
}
+ url.value = newUrl;
}
};
From 1114a191789db017cd39169ab9f268b0f3c9136a Mon Sep 17 00:00:00 2001
From: Andrea Delgado <114981520+andreadlgdo@users.noreply.github.com>
Date: Mon, 8 Jul 2024 13:42:30 +0200
Subject: [PATCH 3/6] fix: fix warning
---
.../x-modules/url/components/url-handler.vue | 20 +++++--------------
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/packages/x-components/src/x-modules/url/components/url-handler.vue b/packages/x-components/src/x-modules/url/components/url-handler.vue
index 20b3bb41ff..1512f29dfa 100644
--- a/packages/x-components/src/x-modules/url/components/url-handler.vue
+++ b/packages/x-components/src/x-modules/url/components/url-handler.vue
@@ -286,32 +286,22 @@
* @internal
*/
const isNavigatingFromPdp = (): boolean => {
- //const isPagePersisted = isPagePersisted.value;
+ const isPagePersistedValue = isPagePersisted.value;
const navigationEntries = window.performance.getEntriesByType('navigation');
const navigationType = (navigationEntries[0] as PerformanceNavigationTiming)?.type;
const useFallbackStrategy =
- window.performance.navigation &&
+ !navigationEntries.length &&
(isArrayEmpty(navigationEntries) || navigationType === 'reload');
// Reset internal isPagePersisted property value
isPagePersisted.value = false;
if (useFallbackStrategy) {
- const {
- type: fallbackNavigationType,
- TYPE_BACK_FORWARD,
- TYPE_NAVIGATE
- } = window.performance.navigation;
- const isNavigatingInSpa =
- !!snippetConfig?.isSpa && fallbackNavigationType === TYPE_NAVIGATE;
- return (
- fallbackNavigationType === TYPE_BACK_FORWARD ||
- isNavigatingInSpa ||
- isPagePersisted.value
- );
+ const isNavigatingInSpa = !!snippetConfig?.isSpa && navigationType === 'navigate';
+ return navigationType === 'back_forward' || isNavigatingInSpa || isPagePersistedValue;
} else {
const isNavigatingInSpa = !!snippetConfig?.isSpa && navigationType === 'navigate';
- return navigationType === 'back_forward' || isNavigatingInSpa || isPagePersisted.value;
+ return navigationType === 'back_forward' || isNavigatingInSpa || isPagePersistedValue;
}
};
From 5246addc6ec9e5967d51623b1bae2d0ff79ff071 Mon Sep 17 00:00:00 2001
From: Andrea Delgado <114981520+andreadlgdo@users.noreply.github.com>
Date: Tue, 9 Jul 2024 10:33:05 +0200
Subject: [PATCH 4/6] fix: try to fix test e2e
---
packages/x-components/tests/e2e/url.feature | 1 +
1 file changed, 1 insertion(+)
diff --git a/packages/x-components/tests/e2e/url.feature b/packages/x-components/tests/e2e/url.feature
index 5f4e070add..cf48f5cc97 100644
--- a/packages/x-components/tests/e2e/url.feature
+++ b/packages/x-components/tests/e2e/url.feature
@@ -38,6 +38,7 @@ Feature: Url component
Scenario Outline: 4. Extra params are properly restored when navigating
Given a URL with query parameter "lego"
+ And a tracking API with a known response
Then search request contains extra parameter "store" with value ""
And url doesn't contain parameter "store" with value ""
When selecting store ""
From 21a72ad0735fd858e20d7cfcad173b8de72ecc56 Mon Sep 17 00:00:00 2001
From: Andrea Delgado <114981520+andreadlgdo@users.noreply.github.com>
Date: Tue, 9 Jul 2024 13:36:39 +0200
Subject: [PATCH 5/6] fix: remove line of test e2e
---
packages/x-components/tests/e2e/url.feature | 1 -
1 file changed, 1 deletion(-)
diff --git a/packages/x-components/tests/e2e/url.feature b/packages/x-components/tests/e2e/url.feature
index cf48f5cc97..5f4e070add 100644
--- a/packages/x-components/tests/e2e/url.feature
+++ b/packages/x-components/tests/e2e/url.feature
@@ -38,7 +38,6 @@ Feature: Url component
Scenario Outline: 4. Extra params are properly restored when navigating
Given a URL with query parameter "lego"
- And a tracking API with a known response
Then search request contains extra parameter "store" with value ""
And url doesn't contain parameter "store" with value ""
When selecting store ""
From 1380db7bd6a7a68fc377ced2751ef8c009345217 Mon Sep 17 00:00:00 2001
From: Diego Pascual
Date: Wed, 10 Jul 2024 13:23:28 +0200
Subject: [PATCH 6/6] fix `ExtraParamsLoadedFromUrl` payload
---
.../x-components/src/x-modules/url/components/url-handler.vue | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/packages/x-components/src/x-modules/url/components/url-handler.vue b/packages/x-components/src/x-modules/url/components/url-handler.vue
index 1512f29dfa..17b7738eb7 100644
--- a/packages/x-components/src/x-modules/url/components/url-handler.vue
+++ b/packages/x-components/src/x-modules/url/components/url-handler.vue
@@ -38,7 +38,7 @@
setup: function (props, { attrs }) {
const $x = use$x();
- const initialExtraParams: Dictionary = useState('url', ['initialExtraParams']);
+ const initialExtraParams = useState('url', ['initialExtraParams']).initialExtraParams;
/**
* The {@link SnippetConfig} provided by an ancestor.
@@ -268,7 +268,7 @@
}
return params;
},
- { all: { ...initialUrlState }, extra: { ...initialExtraParams } }
+ { all: { ...initialUrlState }, extra: { ...initialExtraParams.value } }
);
};