fix: make not connected edges be cleared when entering flow (#8678)
* Fixed output not cleaning edges * Added useEffect to select first output if none is selected * updated useeffect condition * Fixed edges connected being cleared * added handleSelectOutput to dependencies * Fixed loop disconnecting
This commit is contained in:
parent
996fdd4d0a
commit
866076cf06
3 changed files with 25 additions and 4 deletions
|
|
@ -325,6 +325,18 @@ function GenericNode({
|
||||||
[data.id, setNode, setEdges, updateNodeInternals],
|
[data.id, setNode, setEdges, updateNodeInternals],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (
|
||||||
|
data?.selected_output ||
|
||||||
|
(data?.node?.outputs?.filter((output) => !output.group_outputs)?.length ??
|
||||||
|
0) <= 1
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
handleSelectOutput(
|
||||||
|
data.node?.outputs?.find((output) => output.selected) || null,
|
||||||
|
);
|
||||||
|
}, [data.node?.outputs, data?.selected_output, handleSelectOutput]);
|
||||||
|
|
||||||
const [hasChangedNodeDescription, setHasChangedNodeDescription] =
|
const [hasChangedNodeDescription, setHasChangedNodeDescription] =
|
||||||
useState(false);
|
useState(false);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
localStorage.getItem(`dismiss_${flow?.id}`) ?? "[]",
|
localStorage.getItem(`dismiss_${flow?.id}`) ?? "[]",
|
||||||
) as string[],
|
) as string[],
|
||||||
});
|
});
|
||||||
unselectAllNodesEdges(nodes, edges);
|
unselectAllNodesEdges(nodes, newEdges);
|
||||||
if (flow?.id) {
|
if (flow?.id) {
|
||||||
useTweaksStore.getState().initialSetup(nodes, flow?.id);
|
useTweaksStore.getState().initialSetup(nodes, flow?.id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,9 +138,18 @@ export function cleanEdges(nodes: AllNodeType[], edges: EdgeType[]) {
|
||||||
const name = parsedSourceHandle.name;
|
const name = parsedSourceHandle.name;
|
||||||
|
|
||||||
if (sourceNode.type == "genericNode") {
|
if (sourceNode.type == "genericNode") {
|
||||||
const output = sourceNode.data
|
const output =
|
||||||
.node!.outputs?.filter((output) => output.selected)
|
sourceNode.data.node!.outputs?.find(
|
||||||
.find((output) => output.name === name);
|
(output) => output.name === sourceNode.data.selected_output,
|
||||||
|
) ??
|
||||||
|
sourceNode.data.node!.outputs?.find(
|
||||||
|
(output) =>
|
||||||
|
(output.selected ||
|
||||||
|
(sourceNode.data.node!.outputs?.filter(
|
||||||
|
(output) => !output.group_outputs,
|
||||||
|
)?.length ?? 0) <= 1) &&
|
||||||
|
output.name === name,
|
||||||
|
);
|
||||||
|
|
||||||
if (output) {
|
if (output) {
|
||||||
const outputTypes =
|
const outputTypes =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue