Make refresh button actually refresh

This commit is contained in:
Alex Gleason committed 2025-07-20 14:10:52 -05:00
1 parent 6b99d31fdc
commit d1f7063d48
1 file changed
+15 -1
+15 -1
View File
@@ -99,6 +99,20 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
}
}, [projectId]);
const refreshIframe = useCallback(() => {
if (iframeRef.current) {
// Force reload the iframe by updating its src
const currentSrc = iframeRef.current.src;
iframeRef.current.src = '';
// Use a small timeout to ensure the src is cleared before setting it back
setTimeout(() => {
if (iframeRef.current) {
iframeRef.current.src = currentSrc;
}
}, 10);
}
}, []);
const sendResponse = useCallback((message: JSONRPCResponse) => {
if (iframeRef.current?.contentWindow) {
console.log(`Sending response to iframe:`, message);
@@ -269,7 +283,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
<Button
variant="ghost"
size="sm"
onClick={checkForBuiltProject}
onClick={refreshIframe}
className="h-8 w-8 p-0"
>
<RefreshCw className="h-4 w-4" />