Anders Semb Hermansen
b62a30a8dc
fix(live-preview): reset cache per subscription and ignore invalid preview messages ( #13793 )
...
### What?
Fix two live preview issues affecting client-side navigation:
1. Stale preview data leaking between pages using `useLivePreview`.
2. Erroneous fetches to `/api/undefined` and incorrect content rendering
when preview events lack slugs.
### Why?
The live-preview module cached merged preview data globally, which
persisted across route changes, causing a new page to render with the
previous page’s data.
The client attempted to merge when preview events didn’t specify
collectionSlug or globalSlug, producing an endpoint of undefined and
triggering requests to /api/undefined, sometimes overwriting state with
mismatched content.
### How?
Clear the internal cache at the time of `subscribe()` so each page using
`useLivePreview` starts from a clean slate.
In `handleMessage`, only call `mergeData` when `collectionSlug` or
`globalSlug` is present; otherwise return `initialData` and perform no
request.
Fixes #13792
2025-09-12 18:40:24 +00:00
..
2025-09-08 16:38:00 -04:00
2025-09-12 17:43:03 +00:00
2025-09-11 13:24:16 -07:00
2025-05-19 12:36:40 -03:00
2025-09-12 17:43:03 +00:00
2024-11-16 15:30:05 -05:00
2025-06-05 09:19:19 -07:00
2025-09-12 17:43:03 +00:00
2025-04-08 17:25:29 -03:00
2025-05-19 12:36:40 -03:00
2025-09-11 13:24:16 -07:00
2025-06-05 09:19:19 -07:00
2025-09-11 09:14:56 -04:00
2025-08-27 10:24:37 -07:00
2025-05-19 12:36:40 -03:00
2025-06-05 09:19:19 -07:00
2025-08-27 14:11:08 -04:00
2025-06-05 09:19:19 -07:00
2025-05-19 12:36:40 -03:00
2025-05-19 12:36:40 -03:00
2025-05-19 12:36:40 -03:00
2025-06-05 09:19:19 -07:00
2025-08-19 19:44:59 +00:00
2025-05-19 12:36:40 -03:00
2025-09-11 13:24:16 -07:00
2025-09-11 13:24:16 -07:00
2025-09-09 11:43:00 -04:00
2025-06-05 09:19:19 -07:00
2025-09-03 14:29:39 -04:00
2025-06-05 09:19:19 -07:00
2025-06-05 09:19:19 -07:00
2025-08-26 11:03:26 -07:00
2025-09-11 13:24:16 -07:00
2025-09-12 17:43:03 +00:00
2025-09-10 20:46:49 +00:00
2025-09-11 13:24:16 -07:00
2024-10-30 17:56:50 +00:00
2025-09-11 13:24:16 -07:00
2025-08-22 09:44:55 +01:00
2025-05-19 12:36:40 -03:00
2025-09-12 18:40:24 +00:00
2024-08-13 12:54:33 -04:00
2025-09-03 10:27:08 +01:00
2025-05-19 12:36:40 -03:00
2025-09-12 07:46:51 -07:00
2025-06-05 09:19:19 -07:00
2025-05-19 12:36:40 -03:00
2025-05-19 12:36:40 -03:00
2025-06-05 09:19:19 -07:00
2025-06-05 09:19:19 -07:00
2025-06-05 09:19:19 -07:00
2025-08-15 11:56:58 -07:00
2025-09-12 17:43:03 +00:00
2025-08-28 16:12:47 -04:00
2025-06-05 09:19:19 -07:00
2025-08-28 16:12:35 -04:00
2025-06-05 09:19:19 -07:00
2025-06-05 09:19:19 -07:00
2025-06-05 09:19:19 -07:00
2025-06-05 09:19:19 -07:00
2025-09-11 13:24:16 -07:00
2025-08-27 20:32:42 +00:00
2025-07-25 09:10:21 -04:00
2024-07-23 13:44:44 -04:00
2025-07-23 16:48:25 -07:00
2025-06-27 09:13:52 -04:00
2025-07-29 03:25:09 +00:00
2025-07-10 08:00:26 -07:00
2025-07-10 08:00:26 -07:00
2025-07-10 08:00:26 -07:00
2025-07-10 08:00:26 -07:00
2025-07-10 08:00:26 -07:00
2025-09-11 13:24:16 -07:00
2025-06-29 14:20:54 -04:00
2025-09-11 13:24:16 -07:00
2025-09-09 11:31:15 -04:00
2024-07-11 15:59:38 -04:00
2024-05-25 15:45:05 +00:00
2025-06-04 17:34:37 -03:00
2024-03-07 11:33:46 -05:00
2025-06-05 22:01:55 -03:00
2024-12-31 09:14:56 -05:00
2025-07-30 05:52:01 -07:00
2025-08-20 16:31:19 +00:00
2025-07-16 15:17:43 -04:00
2024-08-13 12:54:33 -04:00
2025-03-05 19:14:35 +00:00
2024-09-16 17:02:08 +00:00
2025-09-12 17:43:03 +00:00
2025-07-18 06:48:27 -04:00
2024-11-11 13:59:05 -05:00
2024-10-11 18:54:39 +00:00
2025-02-17 19:50:32 +00:00
2024-10-11 18:54:39 +00:00
2024-12-17 14:49:29 -05:00
2025-07-11 16:34:55 -04:00
2025-09-11 09:14:56 -04:00
2024-05-01 17:35:41 -04:00
2025-02-07 03:24:49 +00:00
2025-06-05 22:01:55 -03:00
2025-07-18 06:48:27 -04:00
2024-08-14 08:57:04 -04:00
2024-10-14 20:02:26 +00:00
2025-03-05 19:14:35 +00:00
2025-05-12 09:41:18 -04:00
2024-06-17 14:25:36 -04:00
2025-02-14 00:08:20 +00:00
2024-03-14 23:53:47 -04:00
2025-01-14 20:00:00 -03:00
2025-03-05 19:14:35 +00:00