Only cut if something is selected

This commit is contained in:
Jacco Kulman 2020-06-21 10:16:16 +02:00
parent 78af17cccf
commit 8a886a7b73

View file

@ -8,7 +8,7 @@ import CopyPasteHOC from './copy-paste-hoc.jsx';
import {selectAllBitmap} from '../helper/bitmap';
import {clearSelection, deleteSelection, getSelectedLeafItems,
selectAllItems, selectAllSegments} from '../helper/selection';
selectAllItems, selectAllSegments, getSelectedRootItems} from '../helper/selection';
import {groupSelection, shouldShowGroup, ungroupSelection, shouldShowUngroup} from '../helper/group';
import {clearSelectedItems, setSelectedItems} from '../reducers/selected-items';
import {changeMode} from '../reducers/modes';
@ -64,9 +64,12 @@ const KeyboardShortcutsHOC = function (WrappedComponent) {
this.changeToASelectMode();
this.props.onPasteFromClipboard();
} else if (event.key === 'x') {
this.props.onCopyToClipboard();
if (deleteSelection(this.props.mode, this.props.onUpdateImage)) {
this.props.setSelectedItems(this.props.format);
const selectedItems = getSelectedRootItems();
if (selectedItems.length > 0) {
this.props.onCopyToClipboard();
if (deleteSelection(this.props.mode, this.props.onUpdateImage)) {
this.props.setSelectedItems(this.props.format);
}
}
event.preventDefault();
} else if (event.key === 'a') {