mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Fix state issues navigating between projects
This commit is contained in:
2 files changed
+17
No files matched your search
@@ -377,6 +377,13 @@ export function PreviewPane({ projectId, activeTab, onToggleView, projectName, o
|
||||
}
|
||||
}, [selectedFile, loadFileContent]);
|
||||
|
||||
// Reset selected file when projectId changes
|
||||
useEffect(() => {
|
||||
setSelectedFile(null);
|
||||
setFileContent('');
|
||||
setMobileCodeView('explorer');
|
||||
}, [projectId]);
|
||||
|
||||
useEffect(() => {
|
||||
checkForBuiltProject();
|
||||
}, [checkForBuiltProject]);
|
||||
|
||||
@@ -71,6 +71,16 @@ export function ProjectView() {
|
||||
loadProject();
|
||||
}, [loadProject]);
|
||||
|
||||
// Reset view state when projectId changes
|
||||
useEffect(() => {
|
||||
if (projectId) {
|
||||
// Reset to preview tab if the new project is previewable, otherwise code
|
||||
setActiveTab(isPreviewable ? 'preview' : 'code');
|
||||
// Reset mobile view to chat when switching projects
|
||||
setMobileView('chat');
|
||||
}
|
||||
}, [projectId, isPreviewable]);
|
||||
|
||||
// Switch away from preview mode if project is not previewable
|
||||
useEffect(() => {
|
||||
if (mobileView === 'preview' && !isPreviewable) {
|
||||
|
||||
Reference in new issue
Block a user