@decocms/blocks 7.48.0 → 7.48.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/blocks",
3
- "version": "7.48.0",
3
+ "version": "7.48.2",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { useEffect } from "react";
2
2
 
3
3
  interface LiveControlsProps {
4
4
  site?: string;
@@ -15,6 +15,21 @@ interface LiveControlsProps {
15
15
  * 3. "." opens admin in same tab, Ctrl/Cmd+"." opens in new tab, Ctrl+Shift+E also works
16
16
  */
17
17
  export function LiveControls({ site, page, flags }: LiveControlsProps) {
18
+ // Keep `window.LIVE.page` in sync with the CURRENT page across SPA
19
+ // navigations. The bootstrap script below reads __DECO_STATE only once (on
20
+ // initial load), so without this effect a client-side navigation would leave
21
+ // window.LIVE.page pointing at the first page rendered — and the "." shortcut
22
+ // would send that page's pathTemplate/id (or the "/*" fallback) instead of the
23
+ // route the user is actually looking at.
24
+ useEffect(() => {
25
+ if (typeof window === "undefined") return;
26
+ const w = window as unknown as { LIVE?: Record<string, unknown> };
27
+ w.LIVE = w.LIVE || {};
28
+ w.LIVE.page = page || {};
29
+ w.LIVE.site = { name: site || "storefront" };
30
+ // eslint-disable-next-line react-hooks/exhaustive-deps
31
+ }, [site, page?.id, page?.pathTemplate]);
32
+
18
33
  return (
19
34
  <>
20
35
  <script