Skip to content

Commit e039264

Browse files
committed
🐛(frontend) fix empty left panel after deleting doc
When we were deleting a parent 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 parent or not, if it is a parent we just redirect to the homepage.
1 parent ca09f9a commit e039264

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ and this project adheres to
88

99
## [Unreleased]
1010

11+
### Fixed
12+
13+
- 🐛(frontend) fix empty left panel after deleting doc #1197
14+
1115
## [3.4.1] - 2025-07-15
1216

1317
### Fixed

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
@@ -11,6 +11,7 @@ import { Trans, useTranslation } from 'react-i18next';
1111

1212
import { Box, Text, TextErrors } from '@/components';
1313

14+
import { useTreeUtils } from '../../doc-tree';
1415
import { useRemoveDoc } from '../api/useRemoveDoc';
1516
import { Doc } from '../types';
1617

@@ -29,25 +30,26 @@ export const ModalRemoveDoc = ({
2930
const { t } = useTranslation();
3031
const { push } = useRouter();
3132
const pathname = usePathname();
33+
const { isParent } = 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 (isParent) {
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)