Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block: Move drag handling to instance-bound handler #4582

Merged
merged 1 commit into from
Jan 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Block: Move drag handling to instance-bound handler
  • Loading branch information
aduth committed Jan 18, 2018
commit 30b79c83881c002c5aca2f6cfa8a6354d0f12085
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