🐛(frontend) fix redirect after deleting a document

We fixed the redirect behavior after deleting a
document to ensure the user stays on the correct page
after deleting a document.
We added a test to avoid regression in the redirect
behavior.
This commit is contained in:
Anthony LC
2026-09-18 15:49:28 +02:00
parent 3402369dce
commit f52224cac9
4 changed files with 14 additions and 10 deletions
+1
View File
@@ -16,6 +16,7 @@ and this project adheres to
### Fixed
- 🐛(export) keep image aspect ratio in PDF columns #2670
- 🐛(frontend) fix redirect after deleting a document #2706
## [v5.7.0] - 2026-09-15
@@ -25,7 +25,7 @@ test.describe('Doc Trashbin', () => {
}) => {
const [title1] = await createDoc(page, 'my-trash-doc-1', browserName, 1);
const [title2] = await createDoc(page, 'my-trash-doc-2', browserName, 1);
await verifyDocName(page, title2);
await page.getByRole('button', { name: 'Share' }).click();
await addNewMember(page, 0, 'Editor');
await page.getByRole('button', { name: 'close' }).click();
@@ -33,10 +33,17 @@ test.describe('Doc Trashbin', () => {
await page.getByRole('button', { name: 'Back to homepage' }).click();
// Delete the first document - Is not displayed
await page.getByRole('link', { name: 'My docs' }).click();
const row1 = await getGridRow(page, title1);
await clickInDocOptionMenu(page, row1, 'Delete');
await page.getByRole('button', { name: 'Delete document' }).click();
await expect(row1.getByText(title1)).toBeHidden();
await expect(
page.getByRole('heading', {
name: 'My docs',
level: 2,
}),
).toBeVisible();
// Star the second document - Is displayed in the starred list
const row2 = await getGridRow(page, title2);
@@ -386,7 +386,7 @@ const DocToolBoxComponent = ({
treeContext?.treeData.getParentId(doc.id) ||
treeContext?.root?.id;
if (isTopParent) {
if (isTopParent && isCurrentDoc) {
void router.push(`/`);
} else if (parentId) {
void router.push(`/docs/${parentId}`).then(() => {
@@ -74,15 +74,11 @@ export const ModalRemoveDoc = ({
const keyboardAction = useKeyboardAction();
const handleClose = () => {
onClose();
};
const handleDelete = () => {
removeDoc({ docId: doc.id });
};
const handleCloseKeyDown = keyboardAction(handleClose);
const handleCloseKeyDown = keyboardAction(onClose);
const handleDeleteKeyDown = keyboardAction(handleDelete);
return (
@@ -90,7 +86,7 @@ export const ModalRemoveDoc = ({
isOpen
closeOnClickOutside
hideCloseButton
onClose={handleClose}
onClose={onClose}
aria-label={t('Delete a doc')}
rightActions={
<>
@@ -100,7 +96,7 @@ export const ModalRemoveDoc = ({
variant="secondary"
fullWidth
autoFocus
onClick={handleClose}
onClick={onClose}
onKeyDown={handleCloseKeyDown}
>
{t('Cancel')}
@@ -131,7 +127,7 @@ export const ModalRemoveDoc = ({
<Box $position="absolute" $css="top: 4px; right: 4px;">
<ButtonCloseModal
aria-label={t('Close the delete modal')}
onClick={handleClose}
onClick={onClose}
onKeyDown={handleCloseKeyDown}
/>
</Box>