@wipco/sdui 0.50.4 → 0.50.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +12 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2830,6 +2830,11 @@ function SduiFragmentBody({
|
|
|
2830
2830
|
}
|
|
2831
2831
|
return /* @__PURE__ */ jsx(SduiFragmentChainContext.Provider, { value: nextChain, children: page.body.map((child, i) => renderChild(child, i, bodyScope, engine)) });
|
|
2832
2832
|
}
|
|
2833
|
+
function urlSeedSettled(state, seeded, baseline) {
|
|
2834
|
+
return Object.keys(seeded).every(
|
|
2835
|
+
(key) => Object.is(state[key], seeded[key]) || !Object.is(state[key], baseline[key])
|
|
2836
|
+
);
|
|
2837
|
+
}
|
|
2833
2838
|
function SduiRenderer({
|
|
2834
2839
|
page,
|
|
2835
2840
|
registry = defaultRegistry,
|
|
@@ -2846,6 +2851,7 @@ function SduiRenderer({
|
|
|
2846
2851
|
const [state, setState] = useState(() => ({ ...initialState ?? {} }));
|
|
2847
2852
|
const urlSeeded = useRef(false);
|
|
2848
2853
|
const urlSeedPending = useRef(null);
|
|
2854
|
+
const urlHomePath = useRef(typeof window !== "undefined" ? window.location.pathname : "");
|
|
2849
2855
|
const [toasts, setToasts] = useState([]);
|
|
2850
2856
|
const toastSeq = useRef(0);
|
|
2851
2857
|
const toastTimers = useRef([]);
|
|
@@ -2881,15 +2887,18 @@ function SduiRenderer({
|
|
|
2881
2887
|
}
|
|
2882
2888
|
}
|
|
2883
2889
|
if (Object.keys(seeded).length > 0) {
|
|
2884
|
-
|
|
2890
|
+
const baseline = {};
|
|
2891
|
+
for (const key of Object.keys(seeded)) baseline[key] = stateRef.current[key];
|
|
2892
|
+
urlSeedPending.current = { seeded, baseline };
|
|
2885
2893
|
setEntries(seeded);
|
|
2886
2894
|
}
|
|
2887
2895
|
}, [page.urlState, setEntries, syncUrlState]);
|
|
2888
2896
|
useEffect(() => {
|
|
2889
2897
|
if (!syncUrlState || !page.urlState?.length || !urlSeeded.current || typeof window === "undefined") return;
|
|
2898
|
+
if (window.location.pathname !== urlHomePath.current) return;
|
|
2890
2899
|
if (urlSeedPending.current) {
|
|
2891
|
-
const seeded = urlSeedPending.current;
|
|
2892
|
-
if (!
|
|
2900
|
+
const { seeded, baseline } = urlSeedPending.current;
|
|
2901
|
+
if (!urlSeedSettled(state, seeded, baseline)) return;
|
|
2893
2902
|
urlSeedPending.current = null;
|
|
2894
2903
|
}
|
|
2895
2904
|
const params = new URLSearchParams(window.location.search);
|