Skip to content

Commit

Permalink
Block: Move drag handling to instance-bound handler (#4582)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth authored Jan 18, 2018
1 parent 6c256dd commit a2d64e1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion editor/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export class BlockListBlock extends Component {
this.stopTypingOnMouseMove = this.stopTypingOnMouseMove.bind( this );
this.mergeBlocks = this.mergeBlocks.bind( this );
this.onFocus = this.onFocus.bind( this );
this.preventDrag = this.preventDrag.bind( this );
this.onPointerDown = this.onPointerDown.bind( this );
this.onKeyDown = this.onKeyDown.bind( this );
this.onBlockError = this.onBlockError.bind( this );
Expand Down Expand Up @@ -280,6 +281,18 @@ export class BlockListBlock extends Component {
}
}

/**
* Prevents default dragging behavior within a block to allow for multi-
* selection to take effect unhampered.
*
* @param {DragEvent} event Drag event.
*
* @returns {void}
*/
preventDrag( event ) {
event.preventDefault();
}

onPointerDown( event ) {
// Not the main button.
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
Expand Down Expand Up @@ -407,7 +420,7 @@ export class BlockListBlock extends Component {
<div
ref={ this.bindBlockNode }
onKeyPress={ this.maybeStartTyping }
onDragStart={ ( event ) => event.preventDefault() }
onDragStart={ this.preventDrag }
onMouseDown={ this.onPointerDown }
onKeyDown={ this.onKeyDown }
onFocus={ this.onFocus }
Expand Down

0 comments on commit a2d64e1

Please sign in to comment.