ZINC-FYP-2022-23 / console

ZINC UI for teaching assistants
1 stars 0 forks source link

fix(gui-pipeline): Ctrl+C cannot copy selected text #35

Closed AnsonH closed 1 year ago

AnsonH commented 1 year ago

Description

Commit 3fa6c71 introduced the Ctrl+C hot key to copy a stage node. However, if we try to highlight some text in the UI and press Ctrl+C to copy it, we cannot copy those text.

For example, highlighting these words and pressing Ctrl+C cannot copy them.

image

Reason

The problem is caused by React Flow's useKeyPress(). If we comment out the following line, Ctrl+C works fine again:

const copyHotKeyPressed = useKeyPress(["Control+c", "Meta+c"]);

Fix

const selectedText = window.getSelection()?.toString();
if (selectedText) {
  navigator.clipboard.writeText(selectedText);
}