Skip to content

Commit

Permalink
fix(TFD-15974): Fix calculate port position with portId action (#4897)
Browse files Browse the repository at this point in the history
  • Loading branch information
aamalric-talend authored Sep 19, 2023
1 parent a5e724a commit d583f76
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/silver-feet-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/react-flow-designer': minor
---

fix(TFD-15974): Fix calculate port position with portId action
14 changes: 14 additions & 0 deletions packages/flow-designer/src/reducers/flow.reducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
2 changes: 1 addition & 1 deletion packages/flow-designer/src/reducers/flow.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit d583f76

Please sign in to comment.