Home stays first, and a reorder shows in the preview
Home has no grip, and dropping onto it is refused — hiding the handle alone would still let something be dragged above the site's front door. Every preview now reloads on the change channel, not just the page builder's own writes. The Layout preview draws the top menu and had no reload token at all, so the one screen where a reorder is visible was the one that never showed it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+15
-2
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useClient } from 'hooks/useClient';
|
||||
import { readableError } from './errors';
|
||||
import { DEVICES, usePreviewable, useViewMode } from './ViewMode';
|
||||
import { useFofosChanged } from './channel';
|
||||
|
||||
/**
|
||||
* A page of the real site, embedded.
|
||||
@@ -209,9 +210,21 @@ export const SitePreview = ({
|
||||
The lesson is the same one as `useClient` two files along: a value rebuilt every render must not be
|
||||
the thing something else keys on.
|
||||
*/
|
||||
/*
|
||||
A change anywhere on the site reloads every preview of it.
|
||||
|
||||
`reloadToken` is the panel's own — the page builder bumps it after its own writes. This is the
|
||||
other half: something ELSE changed the site, and a frame showing the old one is a frame lying. The
|
||||
nav reordering the menu is the case that made it necessary; the Layout preview draws that menu and
|
||||
had no token at all.
|
||||
|
||||
Its purpose is exactly this — "anyone reading it should read it again" — and a preview is a reader.
|
||||
*/
|
||||
const [changed] = useFofosChanged();
|
||||
|
||||
useEffect(() => {
|
||||
setLoaded(0);
|
||||
}, [reloadToken]);
|
||||
}, [reloadToken, changed]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!loaded) return;
|
||||
@@ -334,7 +347,7 @@ export const SitePreview = ({
|
||||
<iframe
|
||||
// The key is what makes `reloadToken` reload: a new key is a new element, so the browser
|
||||
// fetches the document again and `onLoad` runs, which re-injects the builder's chrome.
|
||||
key={reloadToken ?? 0}
|
||||
key={`${reloadToken ?? 0}:${changed}`}
|
||||
ref={frame}
|
||||
// Applied on load as well as on change: the document is replaced on a reload, and the
|
||||
// properties go with it.
|
||||
|
||||
Reference in New Issue
Block a user