From 78af17cccf35a70cb346a051cdbb4d68d5787223 Mon Sep 17 00:00:00 2001 From: Jacco Kulman Date: Sun, 21 Jun 2020 09:57:27 +0200 Subject: [PATCH] shouldShow checks added --- src/hocs/keyboard-shortcuts-hoc.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/hocs/keyboard-shortcuts-hoc.jsx b/src/hocs/keyboard-shortcuts-hoc.jsx index c3796094..1d51d087 100644 --- a/src/hocs/keyboard-shortcuts-hoc.jsx +++ b/src/hocs/keyboard-shortcuts-hoc.jsx @@ -9,7 +9,7 @@ import CopyPasteHOC from './copy-paste-hoc.jsx'; import {selectAllBitmap} from '../helper/bitmap'; import {clearSelection, deleteSelection, getSelectedLeafItems, selectAllItems, selectAllSegments} from '../helper/selection'; -import {groupSelection, ungroupSelection} from '../helper/group'; +import {groupSelection, shouldShowGroup, ungroupSelection, shouldShowUngroup} from '../helper/group'; import {clearSelectedItems, setSelectedItems} from '../reducers/selected-items'; import {changeMode} from '../reducers/modes'; @@ -49,10 +49,14 @@ const KeyboardShortcutsHOC = function (WrappedComponent) { } else if (event.key === 'z') { this.props.onUndo(); } else if (event.shiftKey && event.key.toLowerCase() === 'g') { - ungroupSelection(clearSelectedItems, setSelectedItems, this.props.onUpdateImage); + if (shouldShowUngroup()) { + ungroupSelection(clearSelectedItems, setSelectedItems, this.props.onUpdateImage); + } event.preventDefault(); } else if (event.key === 'g') { - groupSelection(clearSelectedItems, setSelectedItems, this.props.onUpdateImage); + if (shouldShowGroup()) { + groupSelection(clearSelectedItems, setSelectedItems, this.props.onUpdateImage); + } event.preventDefault(); } else if (event.key === 'c') { this.props.onCopyToClipboard();