diff --git a/packages/client/src/components/dialogs/DeleteGroupDialog/index.js b/packages/client/src/components/dialogs/DeleteGroupDialog/index.js index b2a62c0bdb..03a0c8665c 100644 --- a/packages/client/src/components/dialogs/DeleteGroupDialog/index.js +++ b/packages/client/src/components/dialogs/DeleteGroupDialog/index.js @@ -66,7 +66,7 @@ const DeleteGroupDialog = (props) => { if (hasMoreGroups) { onDeleteAllGroups(t); } else { - onDeleteGroup(t, bufferSelection?.id || selection[0].id); + onDeleteGroup(t, bufferSelection?.id || selection[0]?.id); } } catch (err) { toastr.error(err.message); diff --git a/packages/client/src/pages/Home/Section/Header/index.js b/packages/client/src/pages/Home/Section/Header/index.js index 8ec84ec116..02426716ab 100644 --- a/packages/client/src/pages/Home/Section/Header/index.js +++ b/packages/client/src/pages/Home/Section/Header/index.js @@ -224,6 +224,7 @@ const SectionHeaderContent = (props) => { onEmptyTrashAction, getHeaderOptions, setBufferSelection, + setGroupsBufferSelection, } = props; const location = useLocation(); @@ -259,9 +260,9 @@ const SectionHeaderContent = (props) => { }; const onContextOptionsClick = () => { - if (isInsideGroup) return; - - setBufferSelection(selectedFolder); + isInsideGroup + ? setGroupsBufferSelection(currentGroup) + : setBufferSelection(selectedFolder); }; const onSelect = (e) => { @@ -657,6 +658,7 @@ export default inject( currentGroup, getGroupContextOptions, setSelected: setGroupsSelected, + setBufferSelection: setGroupsBufferSelection, insideGroupTempTitle, } = peopleStore.groupsStore; @@ -799,6 +801,7 @@ export default inject( onEmptyTrashAction, getHeaderOptions, setBufferSelection, + setGroupsBufferSelection, }; }, )( diff --git a/packages/client/src/store/GroupsStore.ts b/packages/client/src/store/GroupsStore.ts index 910b6b42c6..dc01472f37 100644 --- a/packages/client/src/store/GroupsStore.ts +++ b/packages/client/src/store/GroupsStore.ts @@ -432,6 +432,10 @@ class GroupsStore { }; onDeleteGroup = async (t, groupId) => { + const { getIsInsideGroup, setInfoPanelSelectedGroup } = this.infoPanelStore; + const isDeletingCurrentGroup = + getIsInsideGroup() && this.currentGroup?.id === groupId; + this.setIsLoading(true); if (!groupId) { @@ -447,6 +451,12 @@ class GroupsStore { this.infoPanelStore.setInfoPanelSelection(null); this.setIsLoading(false); this.peopleStore.dialogStore.setDeleteGroupDialogVisible(false); + + if (isDeletingCurrentGroup) { + setInfoPanelSelectedGroup(null); + this.setBufferSelection(null); + window.DocSpace.navigate(`accounts/groups`); + } } catch (err) { toastr.error(err.message); console.error(err);