File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -330,8 +330,18 @@ const graph = buildGraph([
330330 enableVisualEditing({
331331 history: {
332332 subscribe: (navigate) => {
333+ // Immediately report the current URL on initial mount so Sanity
334+ // Presentation sets frameStateRef.current.url — otherwise
335+ // useNavigatePreviewFrame ignores subsequent location clicks.
336+ navigate({
337+ type: "replace",
338+ url: `${window.location.pathname}${window.location.search}${window.location.hash}`,
339+ });
333340 const onPopState = () => {
334- navigate({ type: "pop", url: window.location.href });
341+ navigate({
342+ type: "pop",
343+ url: `${window.location.pathname}${window.location.search}${window.location.hash}`,
344+ });
335345 };
336346 window.addEventListener("popstate", onPopState);
337347 return () => window.removeEventListener("popstate", onPopState);
@@ -351,10 +361,12 @@ const graph = buildGraph([
351361 currentPerspective,
352362 );
353363 }
354- if (update.type === "replace") {
355- window.location.replace(nextUrl.toString());
356- } else {
357- window.location.assign(nextUrl.toString());
364+ if (nextUrl.href !== window.location.href) {
365+ if (update.type === "replace") {
366+ window.location.replace(nextUrl.toString());
367+ } else {
368+ window.location.assign(nextUrl.toString());
369+ }
358370 }
359371 } else if (update.type === "pop") {
360372 window.history.back();
You can’t perform that action at this time.
0 commit comments