Skip to content

Commit

Permalink
(fix): Update groupsLayout when deleting a group (#4155)
Browse files Browse the repository at this point in the history
* Update groupsLayout when deleting a group

* Rename some variables
  • Loading branch information
dsamojlenko authored Aug 1, 2024
1 parent 2d20df6 commit 3cc69ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,19 @@ const ControlledTree: ForwardRefRenderFunction<unknown, TreeDataProviderProps> =
});

deleteGroup(String(item.index));

// When deleting a group, we need to select the previous group
const itemsArray = Object.keys(items);
const deletedItemIndex = itemsArray.indexOf(String(item.index));
const previousItemId =
deletedItemIndex > 0 ? itemsArray[deletedItemIndex - 1] : "start";
setSelectedItems([previousItemId]);
setExpandedItems([previousItemId]);
setId(previousItemId);

// And update the groups layout
await updateGroupsLayout();

autoFlowAll();
setOpenConfirmDeleteDialog(false);
toast.success(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const useUpdateGroupLayout = () => {

const updateGroupsLayout = async () => {
// Add a delay to ensure the tree from previous actions updates before this is called
sleep(3000);
await sleep(2);

const rootItems = environment?.current?.items.root.children as string[];

Expand Down

0 comments on commit 3cc69ba

Please sign in to comment.