Skip to content

Commit

Permalink
Changes per review
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Nov 14, 2018
1 parent ae570c0 commit 875d911
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/editor/src/components/copy-handler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ class CopyHandler extends Component {
}

onCopy( event ) {
const { selectedBlockClientIds, getBlocks } = this.props;
const { hasMultiSelection, selectedBlockClientIds, getBlocks } = this.props;

if ( ! selectedBlockClientIds || selectedBlockClientIds.length === 0 ) {
if ( selectedBlockClientIds.length === 0 ) {
return;
}

// Let native copy behaviour take over in input fields.
if ( selectedBlockClientIds.length === 1 && documentHasSelection() ) {
if ( ! hasMultiSelection && documentHasSelection() ) {
return;
}

Expand All @@ -46,11 +46,11 @@ class CopyHandler extends Component {
}

onCut( event ) {
const { selectedBlockClientIds } = this.props;
const { hasMultiSelection, selectedBlockClientIds } = this.props;

this.onCopy( event );

if ( selectedBlockClientIds && selectedBlockClientIds.length ) {
if ( hasMultiSelection ) {
this.props.onRemove( selectedBlockClientIds );
}
}
Expand All @@ -66,12 +66,14 @@ export default compose( [
getMultiSelectedBlockClientIds,
getSelectedBlockClientId,
getBlocks,
hasMultiSelection,
} = select( 'core/editor' );

const selectedBlockClientId = getSelectedBlockClientId();
const selectedBlockClientIds = selectedBlockClientId ? [ selectedBlockClientId ] : getMultiSelectedBlockClientIds();

return {
hasMultiSelection: hasMultiSelection(),
selectedBlockClientIds,

// We only care about this value when the copy is performed
Expand Down

0 comments on commit 875d911

Please sign in to comment.