From 6274c451af4c94221c5340fa6a9d6df702423bd1 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Mon, 12 Oct 2020 21:02:51 -0700 Subject: [PATCH] COrrectly set the breadcrumbs when using browser back; closes #2485 --- .../server/files/FileEditContainer.tsx | 4 +++- .../server/files/FileManagerBreadcrumbs.tsx | 16 +++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/resources/scripts/components/server/files/FileEditContainer.tsx b/resources/scripts/components/server/files/FileEditContainer.tsx index 87eda2eb5..1faf99e5a 100644 --- a/resources/scripts/components/server/files/FileEditContainer.tsx +++ b/resources/scripts/components/server/files/FileEditContainer.tsx @@ -32,6 +32,7 @@ export default () => { const id = ServerContext.useStoreState(state => state.server.data!.id); const uuid = ServerContext.useStoreState(state => state.server.data!.uuid); + const setDirectory = ServerContext.useStoreActions(actions => actions.files.setDirectory); const { addError, clearFlashes } = useFlash(); let fetchFileContent: null | (() => Promise) = null; @@ -39,8 +40,9 @@ export default () => { useEffect(() => { if (action === 'new') return; - setLoading(true); setError(''); + setLoading(true); + setDirectory(hash.replace(/^#/, '').split('/').filter(v => !!v).slice(0, -1).join('/')); getFileContents(uuid, hash.replace(/^#/, '')) .then(setContent) .catch(error => { diff --git a/resources/scripts/components/server/files/FileManagerBreadcrumbs.tsx b/resources/scripts/components/server/files/FileManagerBreadcrumbs.tsx index 1cdcb05a4..ba43dbd61 100644 --- a/resources/scripts/components/server/files/FileManagerBreadcrumbs.tsx +++ b/resources/scripts/components/server/files/FileManagerBreadcrumbs.tsx @@ -45,13 +45,15 @@ export default ({ withinFileEditor, isNewFile }: Props) => { return (
- {(files && files.length > 0 && !params?.action) && - + {(files && files.length > 0 && !params?.action) ? + + : +
} /home/