Fix for inaccurate bidrectional edges on edge hover

This commit is contained in:
Jordan Pellizzari
2017-03-16 21:11:41 -07:00
committed by jpellizzari
parent 3e2144544b
commit 93e76a94c1
3 changed files with 16 additions and 2 deletions

View File

@@ -540,4 +540,15 @@ describe('RootReducer', () => {
expect(nextState.get('selectedNodeId')).toBeFalsy();
expect(nextState.getIn(['nodeDetails', 'n1'])).toBeFalsy();
});
it('highlights bidirectional edges', () => {
const action = {
type: ActionTypes.ENTER_EDGE,
edgeId: 'abc123-def456'
};
const nextState = reducer(initialState, action);
expect(nextState.get('highlightedEdgeIds').toJS()).toEqual([
'abc123-def456',
'def456-abc123'
]);
});
});

View File

@@ -421,7 +421,10 @@ export function rootReducer(state = initialState, action) {
// highlight edge
state = state.update('highlightedEdgeIds', (highlightedEdgeIds) => {
highlightedEdgeIds = highlightedEdgeIds.clear();
return highlightedEdgeIds.add(action.edgeId);
highlightedEdgeIds = highlightedEdgeIds.add(action.edgeId);
const opposite = action.edgeId.split(EDGE_ID_SEPARATOR).reverse().join(EDGE_ID_SEPARATOR);
highlightedEdgeIds = highlightedEdgeIds.add(opposite);
return highlightedEdgeIds;
});
return state;

View File

@@ -1,7 +1,7 @@
import { fromJS } from 'immutable';
import {
initEdgesFromNodes,
initEdgesFromNodes
} from '../layouter-utils';