-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mrc-5443 Copy variable on drag if Ctrl key is pressed #214
Conversation
@@ -19,11 +19,13 @@ export default ( | |||
const thisSrcGraphConfig = hasHiddenVariables ? "hidden" : graphIndex!.toString(); | |||
|
|||
const startDrag = (evt: DragEvent, variable: string) => { | |||
const { dataTransfer } = evt; | |||
const { dataTransfer, ctrlKey, metaKey } = evt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dislike having to think to work out what abbreviations stand for - had to go back a line to decipher whether evt meant event or environment
expect(setData.mock.calls[0][0]).toBe("variable"); | ||
expect(setData.mock.calls[0][1]).toStrictEqual("S"); | ||
expect(setData.mock.calls[1][0]).toStrictEqual("srcGraphConfig"); | ||
expect(setData.mock.calls[1][1]).toStrictEqual("0"); | ||
expect(setData.mock.calls[2][0]).toBe("copyVar"); | ||
expect(setData.mock.calls[2][1]).toBe("false"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(setData.mock.calls[0][0]).toBe("variable"); | |
expect(setData.mock.calls[0][1]).toStrictEqual("S"); | |
expect(setData.mock.calls[1][0]).toStrictEqual("srcGraphConfig"); | |
expect(setData.mock.calls[1][1]).toStrictEqual("0"); | |
expect(setData.mock.calls[2][0]).toBe("copyVar"); | |
expect(setData.mock.calls[2][1]).toBe("false"); | |
expect(setData.mock.calls[0].slice(0, 2)).toBe(["variable", "S"]); | |
expect(setData.mock.calls[1].slice(0, 2)).toBe(["srcGraphConfig", "0"]); | |
expect(setData.mock.calls[2].slice(0, 2)).toBe(["copyVar", "false"]); |
Easier to read, if it works? Now I can see that copyVar is meant to relate to "false".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't quite work, but toHaveBeenNthCalledWith
gives us much the same thing, so switching to that.
if (s === "copyVar") return "false"; | ||
return null; | ||
} | ||
}; | ||
const dropPanel = wrapper.find(".graph-config-panel"); | ||
await dropPanel.trigger("drop", { dataTransfer }); | ||
expect(mockUpdateSelectedVariables.mock.calls.length).toBe(1); | ||
expect(mockUpdateSelectedVariables.mock.calls[0][1]).toStrictEqual({ | ||
graphIndex: 0, | ||
selectedVariables: ["S", "R", "I"] | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we hold down a ctrl/meta key here, to show that trying to copy a hidden variable on dragging doesn't end up with it existing in both places (hiddens and drag target)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works well and feels very intuitive to use. Also had no idea that key was called meta
If user presses Ctrl (or ⌘) key when dragging variabe to another graph, this makes a copy so graph is retained in the source as well as being added to target.
Dragging to or from Hidden variables ignore Ctrl key.
Now that we can have variables on multiple graphs, this also means that we have to make good on the text "Drag variables here to hide them on all graphs" on Hidden variables, so we search all graph configs for variable to hide rather than just removing from source.
It's not very clear to me why, but I found I now had to specify start and end positions in the e2e drag variable tests. Perhaps something to do with the text change in the drop area meaning the text wraps and height is increased in the default page size? Very odd!