diff --git a/.changeset/silver-feet-exercise.md b/.changeset/silver-feet-exercise.md new file mode 100644 index 00000000000..39ddf987227 --- /dev/null +++ b/.changeset/silver-feet-exercise.md @@ -0,0 +1,5 @@ +--- +'@talend/react-flow-designer': minor +--- + +fix(TFD-15974): Fix calculate port position with portId action diff --git a/packages/flow-designer/src/reducers/flow.reducer.test.ts b/packages/flow-designer/src/reducers/flow.reducer.test.ts index b7be353ed53..784cda1531b 100644 --- a/packages/flow-designer/src/reducers/flow.reducer.test.ts +++ b/packages/flow-designer/src/reducers/flow.reducer.test.ts @@ -184,4 +184,18 @@ describe('calculatePortsPosition behavior', () => { }); expect(calculatePortPosition.mock.calls.length).toEqual(0); }); + + it('should trigger using action with port id', () => { + const calculatePortPosition = jest.fn(); + const givenState = state.setIn(['nodeTypes', '42', 'component'], { calculatePortPosition }); + const action = { + type: 'FLOWDESIGNER_PORT_SET_DATA', + portId: '42', + data: { + flowType: '__default__', + }, + }; + calculatePortsPosition(givenState, action); + expect(calculatePortPosition.mock.calls.length).toEqual(1); + }); }); diff --git a/packages/flow-designer/src/reducers/flow.reducer.ts b/packages/flow-designer/src/reducers/flow.reducer.ts index ef63897deff..7da71b56926 100644 --- a/packages/flow-designer/src/reducers/flow.reducer.ts +++ b/packages/flow-designer/src/reducers/flow.reducer.ts @@ -166,7 +166,7 @@ export function calculatePortsPosition(state: State, action: any) { if (action.nodeId) { nodes.push(state.getIn(['nodes', action.nodeId])); } else if (action.portId) { - nodes.push(state.getIn(['nodes'], state.getIn(['ports', action.portId]).nodeId)); + nodes.push(state.getIn(['nodes', state.getIn(['ports', action.portId]).nodeId])); } else { nodes = state.get('nodes'); }