Skip to content

Commit

Permalink
open sublist when adding item on tree
Browse files Browse the repository at this point in the history
  • Loading branch information
erasta committed Nov 19, 2024
1 parent 1eece60 commit f1e7c61
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions client/src/App/TreeSublist.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import AddIcon from '@mui/icons-material/Add';
import { camelCaseToWords, createNewName } from "../Utils/utils";
import { TreeItem } from "@mui/x-tree-view/TreeItem";
import { assignUuids } from "../Context/TrackUuidUtils";
import { ExperimentTreeNodesExpandedContext } from "../Experiment/ExperimentTreeNodesExpandedProvider";
import { useContext } from "react";

export const TreeSublist = ({
nameTemplate,
Expand All @@ -15,6 +17,10 @@ export const TreeSublist = ({
children,
noAddButton,
}) => {
const {
addExpandedNode,
} = useContext(ExperimentTreeNodesExpandedContext);

const items = data[fieldName] || [];
const key = parentKey + '_' + fieldName;

Expand Down Expand Up @@ -54,6 +60,7 @@ export const TreeSublist = ({
const noNameData = newDataCreator ? newDataCreator() : {};
const theData = assignUuids({ name, ...noNameData });
setData({ ...data, [fieldName]: [...items, theData] });
addExpandedNode(key);
}}
>
<AddIcon />
Expand Down

0 comments on commit f1e7c61

Please sign in to comment.