From 8c9380c35697f767ebc1e2664e22040896644cb2 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Fri, 25 Jul 2025 12:55:29 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(frontend)=20fix=20empty=20left=20p?= =?UTF-8?q?anel=20after=20deleting=20root=20doc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we were deleting a root document, the left panel was getting empty. It was because the panel thought that it was a child document and was trying clear dynamically the panel. Now, we are checking if the document is a root or not, if it is a root we just redirect to the homepage. --- CHANGELOG.md | 1 + .../components/ModalRemoveDoc.tsx | 24 +++++++++---------- .../components/DocTreeItemActions.tsx | 6 ++--- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fad24c4ac..bc0979818e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to ### Fixed - 🐛(service-worker) Fix useOffline Maximum update depth exceeded #1196 +- 🐛(frontend) fix empty left panel after deleting root doc #1197 - 🐛(helm) charts generate invalid YAML for collaboration API / WS #890 - 🐛(frontend) 401 redirection overridden #1214 diff --git a/src/frontend/apps/impress/src/features/docs/doc-management/components/ModalRemoveDoc.tsx b/src/frontend/apps/impress/src/features/docs/doc-management/components/ModalRemoveDoc.tsx index a85b5f676e..c206ebfc43 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-management/components/ModalRemoveDoc.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-management/components/ModalRemoveDoc.tsx @@ -15,15 +15,15 @@ import { useRemoveDoc } from '../api/useRemoveDoc'; import { Doc } from '../types'; interface ModalRemoveDocProps { - onClose: () => void; doc: Doc; - afterDelete?: (doc: Doc) => void; + onClose: () => void; + onSuccess?: (doc: Doc) => void; } export const ModalRemoveDoc = ({ - onClose, doc, - afterDelete, + onClose, + onSuccess, }: ModalRemoveDocProps) => { const { toast } = useToastProvider(); const { t } = useTranslation(); @@ -35,19 +35,17 @@ export const ModalRemoveDoc = ({ error, } = useRemoveDoc({ onSuccess: () => { - toast(t('The document has been deleted.'), VariantType.SUCCESS, { - duration: 4000, - }); - if (afterDelete) { - afterDelete(doc); - return; - } - - if (pathname === '/') { + if (onSuccess) { + onSuccess(doc); + } else if (pathname === '/') { onClose(); } else { void push('/'); } + + toast(t('The document has been deleted.'), VariantType.SUCCESS, { + duration: 4000, + }); }, }); diff --git a/src/frontend/apps/impress/src/features/docs/doc-tree/components/DocTreeItemActions.tsx b/src/frontend/apps/impress/src/features/docs/doc-tree/components/DocTreeItemActions.tsx index c0ad2447f3..6f3011844c 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-tree/components/DocTreeItemActions.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-tree/components/DocTreeItemActions.tsx @@ -125,7 +125,7 @@ export const DocTreeItemActions = ({ }, }); - const afterDelete = () => { + const onSuccessDelete = () => { if (parentId) { void router.push(`/docs/${parentId}`).then(() => { setTimeout(() => { @@ -133,7 +133,7 @@ export const DocTreeItemActions = ({ }, 100); }); } else if (doc.id === treeContext?.root?.id && !parentId) { - void router.push(`/docs/`); + void router.push(`/`); } else if (treeContext && treeContext.root) { void router.push(`/docs/${treeContext.root.id}`).then(() => { setTimeout(() => { @@ -193,7 +193,7 @@ export const DocTreeItemActions = ({ )}