Skip to content

Commit 368c2bf

Browse files
fix(ui): clicking node collapse button does not bring node to front (#4437)
## What type of PR is this? (check all applicable) - [ ] Refactor - [ ] Feature - [x] Bug Fix - [ ] Optimization - [ ] Documentation Update - [ ] Community Node Submission ## Description fix(ui): clicking node collapse button does not bring node to front ## Related Tickets & Documents <!-- For pull requests that relate or close an issue, please include them below. For example having the text: "closes #1234" would connect the current pull request to issue 1234. And when we merge the pull request, Github will automatically close the issue. --> - Related Issue https://discord.com/channels/1020123559063990373/1130288930319761428/1147333454632071249 - Closes #4438
2 parents 56204e8 + 0a70a85 commit 368c2bf

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

invokeai/frontend/web/src/features/nodes/components/flow/nodes/common/NodeWrapper.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,20 @@ import { stateSelector } from 'app/store/store';
99
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
1010
import NodeSelectionOverlay from 'common/components/NodeSelectionOverlay';
1111
import { useMouseOverNode } from 'features/nodes/hooks/useMouseOverNode';
12+
import { nodeExclusivelySelected } from 'features/nodes/store/nodesSlice';
1213
import {
1314
DRAG_HANDLE_CLASSNAME,
1415
NODE_WIDTH,
1516
} from 'features/nodes/types/constants';
1617
import { NodeStatus } from 'features/nodes/types/types';
1718
import { contextMenusClosed } from 'features/ui/store/uiSlice';
18-
import { PropsWithChildren, memo, useCallback, useMemo } from 'react';
19+
import {
20+
MouseEvent,
21+
PropsWithChildren,
22+
memo,
23+
useCallback,
24+
useMemo,
25+
} from 'react';
1926

2027
type NodeWrapperProps = PropsWithChildren & {
2128
nodeId: string;
@@ -57,9 +64,15 @@ const NodeWrapper = (props: NodeWrapperProps) => {
5764

5865
const opacity = useAppSelector((state) => state.nodes.nodeOpacity);
5966

60-
const handleClick = useCallback(() => {
61-
dispatch(contextMenusClosed());
62-
}, [dispatch]);
67+
const handleClick = useCallback(
68+
(e: MouseEvent<HTMLDivElement>) => {
69+
if (!e.ctrlKey && !e.altKey && !e.metaKey && !e.shiftKey) {
70+
dispatch(nodeExclusivelySelected(nodeId));
71+
}
72+
dispatch(contextMenusClosed());
73+
},
74+
[dispatch, nodeId]
75+
);
6376

6477
return (
6578
<Box

invokeai/frontend/web/src/features/nodes/store/nodesSlice.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,17 @@ const nodesSlice = createSlice({
443443
}
444444
node.data.notes = notes;
445445
},
446+
nodeExclusivelySelected: (state, action: PayloadAction<string>) => {
447+
const nodeId = action.payload;
448+
state.nodes = applyNodeChanges(
449+
state.nodes.map((n) => ({
450+
id: n.id,
451+
type: 'select',
452+
selected: n.id === nodeId ? true : false,
453+
})),
454+
state.nodes
455+
);
456+
},
446457
selectedNodesChanged: (state, action: PayloadAction<string[]>) => {
447458
state.selectedNodes = action.payload;
448459
},
@@ -892,6 +903,7 @@ export const {
892903
nodeEmbedWorkflowChanged,
893904
nodeIsIntermediateChanged,
894905
mouseOverNodeChanged,
906+
nodeExclusivelySelected,
895907
} = nodesSlice.actions;
896908

897909
export default nodesSlice.reducer;

0 commit comments

Comments
 (0)