feat(preview): make address bar interactive for routing inside iframe
This commit is contained in:
@@ -152,6 +152,7 @@ export default function PreviewTab() {
|
||||
|
||||
const deviceMode = usePreviewToolbarStore((s) => s.deviceMode);
|
||||
const refreshKey = usePreviewToolbarStore((s) => s.refreshKey);
|
||||
const currentPath = usePreviewToolbarStore((s) => s.currentPath);
|
||||
|
||||
// When the user clicks the manual refresh button in the toolbar, we don't
|
||||
// just want to reload the iframe — we also want to trigger the same ghost/zombie
|
||||
@@ -166,8 +167,16 @@ export default function PreviewTab() {
|
||||
}, [refreshKey]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
setIframeSrc(primaryRunning?.url ?? null);
|
||||
}, [primaryRunning?.url]);
|
||||
if (!primaryRunning?.url) {
|
||||
setIframeSrc(null);
|
||||
} else {
|
||||
const base = primaryRunning.url.replace(/\/$/, "");
|
||||
const path = currentPath.startsWith("/")
|
||||
? currentPath
|
||||
: `/${currentPath}`;
|
||||
setIframeSrc(`${base}${path}`);
|
||||
}
|
||||
}, [primaryRunning?.url, currentPath]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!bridge || !iframeSrc || !iframeDomRef.current) return;
|
||||
|
||||
Reference in New Issue
Block a user