diff --git a/invokeai/frontend/web/src/features/nodes/components/flow/Flow.tsx b/invokeai/frontend/web/src/features/nodes/components/flow/Flow.tsx index df233f4a18..75983b1617 100644 --- a/invokeai/frontend/web/src/features/nodes/components/flow/Flow.tsx +++ b/invokeai/frontend/web/src/features/nodes/components/flow/Flow.tsx @@ -17,7 +17,6 @@ import { edgesChanged, nodesChanged, redo, - selectionDeleted, undo, } from 'features/nodes/store/nodesSlice'; import { $flow } from 'features/nodes/store/reactFlowInstance'; @@ -263,8 +262,22 @@ export const Flow = memo(() => { useHotkeys('esc', onEscapeHotkey); const onDeleteHotkey = useCallback(() => { - dispatch(selectionDeleted()); - }, [dispatch]); + const { nodes, edges } = store.getState().nodes.present; + const nodeChanges: NodeChange[] = []; + const edgeChanges: EdgeChange[] = []; + nodes + .filter((n) => n.selected) + .forEach(({ id }) => { + nodeChanges.push({ type: 'remove', id }); + }); + edges + .filter((e) => e.selected) + .forEach(({ id }) => { + edgeChanges.push({ type: 'remove', id }); + }); + dispatch(nodesChanged(nodeChanges)); + dispatch(edgesChanged(edgeChanges)); + }, [dispatch, store]); useHotkeys(['delete', 'backspace'], onDeleteHotkey); return ( diff --git a/invokeai/frontend/web/src/features/nodes/store/nodesSlice.ts b/invokeai/frontend/web/src/features/nodes/store/nodesSlice.ts index 416d7065bb..70ac801009 100644 --- a/invokeai/frontend/web/src/features/nodes/store/nodesSlice.ts +++ b/invokeai/frontend/web/src/features/nodes/store/nodesSlice.ts @@ -347,23 +347,6 @@ export const nodesSlice = createSlice({ state.nodes = []; state.edges = []; }, - selectionDeleted: (state) => { - const selectedNodes = state.nodes.filter((n) => n.selected); - const selectedEdges = state.edges.filter((e) => e.selected); - - const nodeChanges: NodeChange[] = selectedNodes.map((n) => ({ - id: n.id, - type: 'remove', - })); - - const edgeChanges: EdgeChange[] = selectedEdges.map((e) => ({ - id: e.id, - type: 'remove', - })); - - state.nodes = applyNodeChanges(nodeChanges, state.nodes); - state.edges = applyEdgeChanges(edgeChanges, state.edges); - }, undo: (state) => state, redo: (state) => state, }, @@ -414,7 +397,6 @@ export const { nodesChanged, nodeUseCacheChanged, notesNodeValueChanged, - selectionDeleted, undo, redo, } = nodesSlice.actions; @@ -530,6 +512,5 @@ export const isAnyNodeOrEdgeMutation = isAnyOf( nodeLabelChanged, nodeNotesChanged, nodeUseCacheChanged, - notesNodeValueChanged, - selectionDeleted + notesNodeValueChanged );