diff --git a/app/components/Sidebar/components/CollectionLink.tsx b/app/components/Sidebar/components/CollectionLink.tsx index 101e2ab1f5..4c71b5b9f4 100644 --- a/app/components/Sidebar/components/CollectionLink.tsx +++ b/app/components/Sidebar/components/CollectionLink.tsx @@ -101,9 +101,12 @@ const CollectionLink: React.FC = ({ collection?.addDocument(newDocument); closeAddingNewChild(); - history.replace(documentEditPath(newDocument)); + history.push({ + pathname: documentEditPath(newDocument), + state: { sidebarContext }, + }); }, - [user, closeAddingNewChild, history, collection, documents] + [user, sidebarContext, closeAddingNewChild, history, collection, documents] ); return ( diff --git a/app/components/Sidebar/components/DocumentLink.tsx b/app/components/Sidebar/components/DocumentLink.tsx index 818a9c2467..97ffa795e3 100644 --- a/app/components/Sidebar/components/DocumentLink.tsx +++ b/app/components/Sidebar/components/DocumentLink.tsx @@ -240,9 +240,21 @@ function InnerDocumentLink( collection?.addDocument(newDocument, node.id); closeAddingNewChild(); - history.replace(documentEditPath(newDocument)); + history.push({ + pathname: documentEditPath(newDocument), + state: { sidebarContext }, + }); }, - [documents, collection, user, node, doc, history, closeAddingNewChild] + [ + documents, + collection, + sidebarContext, + user, + node, + doc, + history, + closeAddingNewChild, + ] ); return (