Skip to content

Commit

Permalink
current state and padding adjustment in TreeViewList component
Browse files Browse the repository at this point in the history
  • Loading branch information
syedsalehinipg committed Apr 15, 2024
1 parent 768f55f commit 5af8709
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/TreeViewList/TreeViewList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const TreeViewList = ({
// state for selected node
const [selectedNode, setSelectedNode] = useState<string>(selected ?? "");

// local state for selected node
const [currentSelection, setCurrentSelection] = useState(selected ?? "");

// state for search input value
const [searchValue, setSearchValue] = useState("");

Expand Down Expand Up @@ -204,8 +207,6 @@ const TreeViewList = ({
flexDirection: "column",
height,
overflow: "hidden",
paddingX: "5px",
paddingY: "2px",
width
})}
>
Expand Down Expand Up @@ -256,6 +257,7 @@ const TreeViewList = ({
const nodeDetails = { isChild };
// update the selected node when a node is selected and it is a child
if (isChild) {
setCurrentSelection(nodeId);
setSelectedNode(nodeId);
}
onNodeSelect(event, nodeId, nodeDetails);
Expand All @@ -270,6 +272,7 @@ const TreeViewList = ({
setExpandedNodes(nodeId);
// call the onNodeToggle function if it is defined
if (onNodeToggle) {
setSelectedNode(currentSelection);
onNodeToggle(event, nodeId);
}
}}
Expand Down Expand Up @@ -353,7 +356,7 @@ const TooltipTreeItem = (
{...rest}
sx={theme => ({
color: theme.palette.text.primary,
padding: "5px"
paddingY: "5px"
})}
onMouseOver={event => {
event.stopPropagation();
Expand Down

0 comments on commit 5af8709

Please sign in to comment.