Skip to content

Commit

Permalink
fix: keeping inserting node selected when clicking other nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasfeijo committed Sep 13, 2023
1 parent c9dd68b commit 9c41e65
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/Menu/Items/NodeTreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface CustomTreeItemProps {
renderNodes: (nodes: INode[]) => JSX.Element[];
setSelected: (selected: string) => void;
emptyEditingNode: IEditingNode;
editingNode: IEditingNode;
setEditingNode: (editingNode: IEditingNode) => void;
handleUpdate: () => Promise<void>;
data: any;
Expand All @@ -39,6 +40,7 @@ const CustomTreeItem = ({
renderNodes,
setSelected,
emptyEditingNode,
editingNode,
setEditingNode,
handleUpdate,
data,
Expand Down Expand Up @@ -139,6 +141,10 @@ const CustomTreeItem = ({
const onNodeClick = (event: React.SyntheticEvent) => {
event.stopPropagation();
event.preventDefault();
if (editingNode.id === -1) {
setSelected('-1');
return;
}
const itemMeta = { ...meta };
data?.menu.meta?.forEach(m => {
const defaultValue = (meta || {})[m.id] || m.defaultValue;
Expand Down Expand Up @@ -308,6 +314,7 @@ export const NodeTreeView = ({
renderNodes={renderNodes}
setSelected={setSelected}
emptyEditingNode={emptyEditingNode}
editingNode={editingNode}
setEditingNode={setEditingNode}
handleUpdate={handleUpdate}
data={data}
Expand Down

0 comments on commit 9c41e65

Please sign in to comment.