From f33089e1cfcadbe02760af2a987bbef3f830fa8b Mon Sep 17 00:00:00 2001 From: Kirill Shumilov Date: Fri, 12 Jan 2018 13:53:56 +0300 Subject: [PATCH] fix(xod-client): fix copying of text outside inputs (E.G. QuickHelp) --- packages/xod-client/src/editor/actions.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/xod-client/src/editor/actions.js b/packages/xod-client/src/editor/actions.js index bbfa2c26..6a34c511 100644 --- a/packages/xod-client/src/editor/actions.js +++ b/packages/xod-client/src/editor/actions.js @@ -312,16 +312,19 @@ const getClipboardEntities = (state) => { }; export const copyEntities = event => (dispatch, getState) => { - if (isInput(document.activeElement)) return; + // If user clicked somewhere on Patch (select Node or something else + // except editing comment node) activeElement will be
+ // with className `PatchWrapper`. + if (document.activeElement.className === 'PatchWrapper') { + const state = getState(); - const state = getState(); - - // linter confuses array and a Maybe - // eslint-disable-next-line array-callback-return - getClipboardEntities(state).map((entities) => { - event.clipboardData.setData(getClipboardDataType(), JSON.stringify(entities, null, 2)); - event.preventDefault(); - }); + // linter confuses array and a Maybe + // eslint-disable-next-line array-callback-return + getClipboardEntities(state).map((entities) => { + event.clipboardData.setData(getClipboardDataType(), JSON.stringify(entities, null, 2)); + event.preventDefault(); + }); + } }; export const pasteEntities = event => (dispatch, getState) => {