Skip to content

Commit

Permalink
small change to delete key handling
Browse files Browse the repository at this point in the history
  • Loading branch information
skomputer committed May 12, 2016
1 parent 73f3806 commit aa663d0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 25 deletions.
3 changes: 1 addition & 2 deletions app/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ export function deleteCaption(captionId) {
return { type: DELETE_CAPTION, captionId };
}

export function deleteSelection(event, selection) {
event.preventDefault();
export function deleteSelection(selection) {
return { type: DELETE_SELECTION, selection };
}

Expand Down
5 changes: 4 additions & 1 deletion app/components/Root.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ class Root extends Component {
'resetZoom': () => dispatch(resetZoom()),
'shiftDown': () => this.setState({ shiftKey: true }),
'shiftUp': () => this.setState({ shiftKey: false }),
'delete': (event) => dispatch(deleteSelection(event, selection))
'delete': (event) => {
event.preventDefault();
dispatch(deleteSelection(selection));
}
};

let graphApi = {
Expand Down
10 changes: 0 additions & 10 deletions app/components/__tests__/Edge-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,4 @@ describe("Edge Component", () => {
TestUtils.Simulate.click(select);
expect(clickEdge.mock.calls[0][0]).toBe(data.id);
});

it("should be removed when delete hotkey is pressed", () => {
let deleteEdge = jest.genMockFunction();
let edge = TestUtils.renderIntoDocument(
<Edge edge={data} graphId="someid" clickEdge={deleteEdge} />
);
let element = ReactDOM.findDOMNode(edge);
TestUtils.Simulate.keyDown(element, {key: "Delete", keyCode: 46, which: 46});
expect(deleteEdge.mock.calls[0]).toBeUndefined();
});
});
10 changes: 0 additions & 10 deletions app/components/__tests__/Node-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,4 @@ describe("Node Component", () => {

expect(moveNode.mock.calls.length).toBe(1);
});

it("should be removed when delete hotkey is pressed", () => {
let deleteNode = jest.genMockFunction();
let wrapper = shallow(
<Node node={data} graph={{id: "someid"}} clickNode={deleteNode} />
);
let element = wrapper.find("g.node");
TestUtils.Simulate.keyDown(element, {key: "Delete", keyCode: 46, which: 46});
expect(deleteNode.mock.calls[0]).toBeUndefined();
});
});
4 changes: 2 additions & 2 deletions app/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ class Oligrapher {
this.root.dispatchProps.dispatch(deselectAll());
}

deleteSelection(event) {
this.root.dispatchProps.dispatch(deleteSelection(event, this.getSelection()));
deleteSelection() {
this.root.dispatchProps.dispatch(deleteSelection(this.getSelection()));
}

updateNode(nodeId, data) {
Expand Down

0 comments on commit aa663d0

Please sign in to comment.