Skip to content

Commit b6caad8

Browse files
committed
🐛(frontend) fix empty left panel after deleting root doc
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.
1 parent 941ad09 commit b6caad8

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ and this project adheres to
88

99
## [Unreleased]
1010

11-
## Fixed
11+
### Fixed
1212

13+
- 🐛(frontend) fix empty left panel after deleting root doc #1197
1314
- 🐛(helm) charts generate invalid YAML for collaboration API / WS #890
1415

1516
## [3.4.2] - 2025-07-18

src/frontend/apps/impress/src/features/docs/doc-management/components/ModalRemoveDoc.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { useRouter } from 'next/router';
1010
import { Trans, useTranslation } from 'react-i18next';
1111

1212
import { Box, Text, TextErrors } from '@/components';
13+
import { useTreeUtils } from '@/docs/doc-tree';
1314

1415
import { useRemoveDoc } from '../api/useRemoveDoc';
1516
import { Doc } from '../types';
@@ -29,25 +30,26 @@ export const ModalRemoveDoc = ({
2930
const { t } = useTranslation();
3031
const { push } = useRouter();
3132
const pathname = usePathname();
33+
const { isCurrentRoot } = useTreeUtils(doc);
3234
const {
3335
mutate: removeDoc,
3436
isError,
3537
error,
3638
} = useRemoveDoc({
3739
onSuccess: () => {
38-
toast(t('The document has been deleted.'), VariantType.SUCCESS, {
39-
duration: 4000,
40-
});
41-
if (afterDelete) {
40+
if (isCurrentRoot) {
41+
void push('/');
42+
} else if (afterDelete) {
4243
afterDelete(doc);
43-
return;
44-
}
45-
46-
if (pathname === '/') {
44+
} else if (pathname === '/') {
4745
onClose();
4846
} else {
4947
void push('/');
5048
}
49+
50+
toast(t('The document has been deleted.'), VariantType.SUCCESS, {
51+
duration: 4000,
52+
});
5153
},
5254
});
5355

0 commit comments

Comments
 (0)